玲珑杯 Round 19 A simple math problem

Posted 十年换你一句好久不见

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了玲珑杯 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(1n109)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;
}

 

以上是关于玲珑杯 Round 19 A simple math problem的主要内容,如果未能解决你的问题,请参考以下文章

“玲珑杯”ACM比赛 Round #19题解&源码A,规律,B,二分,C,牛顿迭代法,D,平衡树,E,概率dp

“玲珑杯”ACM比赛 Round #19 B -- Buildings (RMQ + 二分)

玲珑杯 Round 19 B Buildings (RMQ + 二分)

玲珑杯”ACM比赛 Round #19 B 维护单调栈

“玲珑杯”ACM比赛 Round #19 B -- Buildings

“玲珑杯”ACM比赛 Round #18