• 玲珑杯 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);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+i);
                    break;
                }
            }
        }
        return 0;
    }
  • 相关阅读:
    COGS 2075. [ZLXOI2015][异次元圣战III]ZLX的陨落
    51nod 1099 任务执行顺序
    洛谷 P1215 [USACO1.4]母亲的牛奶 Mother's Milk
    洛谷 P3395 路障
    2017.10.25 模拟赛
    COGS 146. [USACO Jan08] 贝茜的晨练计划
    洛谷 P3905 道路重建
    COGS 678. 双重回文数
    洛谷 P1509 找啊找啊找GF
    51nod 1366 贫富差距
  • 原文地址:https://www.cnblogs.com/shinianhuanniyijuhaojiubujian/p/7259199.html
Copyright © 2020-2023  润新知