玲珑杯”ACM比赛 Round #19 A simple math problem

来源:互联网 发布:妙笔生花软件安卓 编辑:程序博客网 时间:2024/05/14 22:19

A – A simple math problem
Time Limit:2s Memory Limit:128MByte

Submissions:1577Solved:265

DESCRIPTION
You have a sequence
a
n
an, which satisfies:
这里写图片描述
Now you should find the value of

10
a
n

⌊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

10
9
)
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<stdio.h>#include<string>#include<string.h>#include<math.h>#include<iostream>#include<algorithm>using namespace std;#define LL long longint main(){    LL n;    while(~scanf("%lld",&n))    {        if(n<=10)            printf("%lld\n",n);        else if(n>10&&n<=99)            printf("%lld\n",n+1);        else if(n>99&&n<=998)            printf("%lld\n",n+2);        else if(n>998&&n<=9997)            printf("%lld\n",n+3);        else if(n>9997&&n<=99996)            printf("%lld\n",n+4);        else if(n>99996&&n<=999995)            printf("%lld\n",n+5);        else if(n>999995&&n<=9999994)            printf("%lld\n",n+6);        else if(n>9999994&&n<=99999993)            printf("%lld\n",n+7);        else if(n>99999993&&n<=999999992)            printf("%lld\n",n+8);        else if(n>999999991)            printf("%lld\n",n+9);        //printf("%lld\n",(int)log10(n));    }    return 0;}