結果
問題 | No.1651 Removing Cards |
ユーザー |
![]() |
提出日時 | 2021-08-20 23:12:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 382 ms / 2,000 ms |
コード長 | 3,193 bytes |
コンパイル時間 | 2,526 ms |
コンパイル使用メモリ | 217,884 KB |
最終ジャッジ日時 | 2025-01-24 00:30:01 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#pragma GCC optimize("Ofast")#pragma GCC optimize("unroll-loops")#pragma GCC optimize("inline")#include<bits/stdc++.h>using namespace std;inline int my_getchar_unlocked(){static char buf[1048576];static int s = 1048576;static int e = 1048576;if(s == e && e == 1048576){e = fread_unlocked(buf, 1, 1048576, stdin);s = 0;}if(s == e){return EOF;}return buf[s++];}inline void rd(int &x){int k;int m=0;x=0;for(;;){k = my_getchar_unlocked();if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){k = my_getchar_unlocked();if(k<'0'||k>'9'){break;}x=x*10+k-'0';}if(m){x=-x;}}inline void rd(long long &x){int k;int m=0;x=0;for(;;){k = my_getchar_unlocked();if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){k = my_getchar_unlocked();if(k<'0'||k>'9'){break;}x=x*10+k-'0';}if(m){x=-x;}}inline int rd_int(void){int x;rd(x);return x;}struct MY_WRITER{char buf[1048576];int s;int e;MY_WRITER(){s = 0;e = 1048576;}~MY_WRITER(){if(s){fwrite_unlocked(buf, 1, s, stdout);}}};MY_WRITER MY_WRITER_VAR;void my_putchar_unlocked(int a){if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);MY_WRITER_VAR.s = 0;}MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;}inline void wt_L(char a){my_putchar_unlocked(a);}inline void wt_L(long long x){int s=0;int m=0;char f[20];if(x<0){m=1;x=-x;}while(x){f[s++]=x%10;x/=10;}if(!s){f[s++]=0;}if(m){my_putchar_unlocked('-');}while(s--){my_putchar_unlocked(f[s]+'0');}}template<class S, class T> inline S divup_L(S a, T b){return (a+b-1)/b;}int K;long long N;int sz;long long arr[1000000];int main(){int xr20shxY;rd(K);arr[sz++] = 1;while(arr[sz-1] < 1000000000000000000LL){long long Q5VJL1cS;long long e98WHCEY;long long cTE1_r3A;Q5VJL1cS = 0;e98WHCEY = 2000000000000000000LL;while(Q5VJL1cS < e98WHCEY){if((Q5VJL1cS + e98WHCEY)%2==0){cTE1_r3A = (Q5VJL1cS + e98WHCEY) / 2;}else{cTE1_r3A = (Q5VJL1cS + e98WHCEY - 1) / 2;}if( cTE1_r3A - ((divup_L(cTE1_r3A,K))) >= arr[sz-1] ){e98WHCEY = cTE1_r3A;}else{Q5VJL1cS = cTE1_r3A + 1;}}N =e98WHCEY;arr[sz++] = N;}int WYIGIcGE = rd_int();for(xr20shxY=(0);xr20shxY<(WYIGIcGE);xr20shxY++){rd(N);N = arr[upper_bound(arr,arr+sz,N) - arr - 1];wt_L(N);wt_L('\n');}return 0;}// cLay version 20210819-1 [beta]// --- original code ---// int K; ll N;// int sz; ll arr[1d6];// {// rd(K);// arr[sz++] = 1;// while(arr[sz-1] < 1d18){// N = bsearch_min[ll,x,0,2d18]( x - (x /+ K) >= arr[sz-1] );// arr[sz++] = N;// }// REP(rd_int()){// rd(N);// N = arr[upper_bound(arr,arr+sz,N) - arr - 1];// wt(N);// }// }