玲珑杯”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:
![](http://www.ifrog.cc/uploads/2017/1901.png)
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
解法:
![](http://images.cnblogs.com/cnblogs_com/zxy160/1045032/t_IMG_20170729_175043.jpg)
然后暴力打表找规律
Time Limit:2s Memory Limit:128MByte
Submissions:1577Solved:265
DESCRIPTION
You have a sequence
a
n
an, which satisfies:
![](http://www.ifrog.cc/uploads/2017/1901.png)
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
解法:
![](http://images.cnblogs.com/cnblogs_com/zxy160/1045032/t_IMG_20170729_175043.jpg)
然后暴力打表找规律
#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; }
相关文章推荐
- “玲珑杯”ACM比赛 Round #16 Down the Rabbit Hole
- “玲珑杯”ACM比赛 Round #18 B -- 数论你还会快速幂【规律】
- Lonlife-ACM 1005 - Spoon Devil's RP Test(同余定理)——“玲珑杯”acm比赛-试运行赛
- 玲珑杯”ACM比赛 Round #4 1054 - String cut 暴力。学到了扫描的另一种思想
- “玲珑杯”ACM比赛 Round #7
- “玲珑杯”ACM比赛 Round #24: C. この戦いが終わったら(BFS+bitset优化暴力)
- “玲珑杯”ACM比赛 Round #13 题解&源码
- “玲珑杯”ACM比赛 Round #18 C -- 图论你先敲完模板【Dp】
- 【“玲珑杯”ACM比赛 Round #20 H】康娜的数学课
- 玲珑杯”ACM比赛 Round #4 E -- array【DP】
- “玲珑杯”ACM比赛 Round #10-A-Black and White
- “玲珑杯”ACM比赛 Round #12【dp】
- “玲珑杯”ACM比赛 Round #18 A -- 计算几何你瞎暴力(计算几何)
- “玲珑杯”ACM比赛 Round #18 A -- 计算几何你瞎暴力
- “玲珑杯”ACM比赛 Round #19
- “玲珑杯”ACM比赛 Round #19题解&源码【A,规律,B,二分,C,牛顿迭代法,D,平衡树,E,概率dp】
- “玲珑杯”ACM比赛 Round #21 【线段树标记】
- “玲珑杯”ACM比赛 Round #4 A -- chess play 【记忆模拟】
- 玲珑杯”ACM比赛 Round #4 G -- See car【Set】
- 玲珑杯”ACM比赛 Round #18 C -- 图论你先敲完模板