您的位置:首页 > 其它

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

2017-07-29 17:57 489 查看
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 long
int 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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: