Comet OJ - Contest #2

后面补的

只做了A题

A题 因自过去而至的残响起舞

简单模拟题 没啥说的

AC代码:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 typedef unsigned long long ull;
 5 
 6 namespace io {
 7     const int SIZE = 1e7 + 10;
 8     char inbuff[SIZE];
 9     char *l, *r;
10     inline void init() {
11         l = inbuff;
12         r = inbuff + fread(inbuff, 1, SIZE, stdin);
13     }
14     inline char gc() {
15         if (l == r) init();
16         return (l != r) ? *(l++) : EOF;
17     }
18     void read(int &x) {
19         x = 0; char ch = gc();
20         while(!isdigit(ch)) ch = gc();
21         while(isdigit(ch)) x = x * 10 + ch - '0', ch = gc();
22     }
23 } using io::read;
24 
25 int main(){
26     ll x;
27     cin>>x;
28     ll sum[100005];
29     memset(sum, 0, sizeof(sum));
30     sum[1] = 1;
31     sum[2] = 2;
32     for (int i = 3; i < 100005; i++)
33         sum[i] = sum[i - 1] + sum[i - 1] / 2;
34     for (int i = 1; i < 100005; i++){
35         if (sum[i] > x){
36             cout<<i<<endl;
37             break;
38         }
39     }
40     return 0;
41 }

 

后面看了题解 sum开105就够了 因为i=104时,ai就已经>1e18了

 

posted @ 2019-06-03 18:37  Misuchii  阅读(170)  评论(0编辑  收藏  举报