玲珑杯 Round 19 A simple math problem

Time Limit:2s Memory Limit:128MByte

Submissions:1599Solved:270

DESCRIPTION

You have a sequence anan, which satisfies:

Now you should find the value of ?10an??10an?.

INPUT

The input includes multiple test cases. The number of test case is less than 1000. Each test case contains only one integer n(1≤n≤109)n(1≤n≤109)。

OUTPUT

For each test case, print a line of one number which means the answer.

SAMPLE INPUT

5

20

1314

SAMPLE OUTPUT

5

21

1317

官方题解

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll n,i;
ll quick_pow(ll a,ll b)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=ans*a;
        b>>=1;
        a*=a;
    }
    return ans;
}
int main()
{
    while(scanf("%lld",&n)!=EOF)
    {
        if(n<=10) {printf("%lld\n",n);continue;}
        for(i=0;i<=11;i++)
        {
            if(quick_pow(10,i)-i+2<=n && quick_pow(10,i+1)-i>=n)
            {
                printf("%lld\n",n+i);
                break;
            }
        }
    }
    return 0;
}
时间: 2024-11-02 16:36:52

玲珑杯 Round 19 A simple math problem的相关文章

hdu------(1757)A Simple Math Problem(简单矩阵快速幂)

A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2791    Accepted Submission(s): 1659 Problem Description Lele now is thinking about a simple function f(x). If x < 10 f(x) =

hdu 1757 A Simple Math Problem (乘法矩阵)

A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2441    Accepted Submission(s): 1415 Problem Description Lele now is thinking about a simple function f(x).If x < 10 f(x) =

FZYZ-2071 A Simple Math Problem IX

P2071 -- A Simple Math Problem IX 时间限制:1000MS      内存限制:262144KB 状态:Accepted      标签:    数学问题-博弈论   无   无 Description 给定a,b,n,保证a≥2,b≥1,a^b≤n.两个人在玩游戏,每个人每次可以把a加1,或者把b加1,但是不能违反a^b<=n,无法再进行操作的人就输掉了这一场游戏. 假设两个人都足够聪明,按照最优策略进行游戏,问先手是否有必胜策略. Input Format 第

A Simple Math Problem 矩阵打水题

A Simple Math Problem Lele now is thinking about a simple function f(x). If x < 10 f(x) = x.If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10);And ai(0<=i<=9) can only be 0 or 1 . Now, I will give a0 ~ a9 and two pos

A Simple Math Problem(矩阵快速幂)(寒假闭关第一题,有点曲折啊)

A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 155 Accepted Submission(s): 110   Problem Description Lele now is thinking about a simple function f(x). If x < 10 f(x) = x.If

hdu1757-- A Simple Math Problem(矩阵快速幂优化)

A Simple Math Problem Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description Lele now is thinking about a simple function f(x). If x < 10 f(x) = x. If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2

BestCoder Round #29——A--GTY&#39;s math problem(快速幂(对数法))、B--GTY&#39;s birthday gift(矩阵快速幂)

GTY's math problem Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0 Problem Description GTY is a GodBull who will get an Au in NOI . To have more time to learn alg

HDU 1757 A Simple Math Problem

A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 108 Accepted Submission(s): 77   Problem Description Lele now is thinking about a simple function f(x). If x < 10 f(x) = x.If

hdu 5974 A Simple Math Problem

A Simple Math Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1645    Accepted Submission(s): 468 Problem Description Given two positive integers a and b,find suitable X and Y to meet th