結果
問題 | No.148 試験監督(3) |
ユーザー | LayCurse |
提出日時 | 2015-02-08 23:15:58 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 50 ms / 1,000 ms |
コード長 | 15,129 bytes |
コンパイル時間 | 1,778 ms |
コンパイル使用メモリ | 161,056 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 06:58:54 |
合計ジャッジ時間 | 2,365 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 12 ms
5,248 KB |
testcase_01 | AC | 18 ms
5,376 KB |
testcase_02 | AC | 45 ms
5,376 KB |
testcase_03 | AC | 50 ms
5,376 KB |
testcase_04 | AC | 46 ms
5,376 KB |
testcase_05 | AC | 40 ms
5,376 KB |
testcase_06 | AC | 34 ms
5,376 KB |
testcase_07 | AC | 42 ms
5,376 KB |
testcase_08 | AC | 45 ms
5,376 KB |
testcase_09 | AC | 5 ms
5,376 KB |
testcase_10 | AC | 5 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
コンパイルメッセージ
main.cpp: In function ‘void reader(double*)’: main.cpp:15:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | void reader(double *x){scanf("%lf",x);} | ~~~~~^~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) #define mygc(c) (c)=getchar_unlocked() #define mypc(c) putchar_unlocked(c) #define ll long long #define ull unsigned ll void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(double *x){scanf("%lf",x);} int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;} template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);} template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);} template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);} void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(ll x, char c){int s=0,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)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(double x, char c){printf("%.15f",x);mypc(c);} void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);} void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);} template<class T> void writerLn(T x){writer(x,'\n');} template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');} template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');} template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');} char memarr[77000000]; void *mem = memarr; #define MD 1000000007 int get_inv(ll a, int md){ll t=a,s=md,u=1,v=0,e;while(s){e=t/s;t-=e*s;u-=e*v;swap(t,s);swap(u,v);}if(u<0)u+=md;return u;} ll fact[200000]; const char *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1Bb$!))2f?1FKy&H!C5{#H.;Hz&C?FDY#7.4;q$F0#BT&*$:3^&9??V%/&.*{$'?,&y#G4C8Y4;LHc&'065}#0#*&n%OL1Du$,@%;}$FC5Fd$44*=i218(P7JO4z&?.MHa$2C:-h&'/7(XO&%Eh#)JLOf$#LEHS%(5:2i%H'H$Z#$-=8c%06G;iOOJ;t#I@*.~C8)j$&H5Ms%F4;0]$7M''x%OA80p>F/$m$K>*>e$M;23]&,+5Mv&:;-;`%4#08XP"; ll fact_memo[100000]; template<class T> int extend(const char arr[], T res[]){ int i, j, s = 1, sz = 0; static int cnv[128], fg = 0; if(fg==0) REP(i,33,127) if(i!='"'&&i!='\\') cnv[i]=fg++; if(arr[0]<' ') return 0; res[0] = 0; for(i=0;;i++){ if(arr[i]<' ') break; if(cnv[arr[i]] < 46){ res[sz] = res[sz]*46 + cnv[arr[i]]; } else { res[sz] = res[sz]*46 + (cnv[arr[i]]-46); if(s==-1) res[sz] *= -1, s = 1; res[++sz] = 0; } } return sz; } ll get_fact(int n){ int i; ll f; f = fact_memo[n / 500000]; i = n / 500000 * 500000; while(i<n){ i++; f=f*i%MD; } return f; } int T; ll C, P, CC; char buf[200000]; int main(){ int i, j, k; ll res; extend(fact_str, fact_memo); reader(&T); while(T--){ C = P = CC = 0; k = reader(buf); rep(i,k){ C = (C*10+buf[i]-'0') % MD; CC = CC*10+buf[i]-'0'; } if(k>15) CC = 1000000000000000000LL; k = reader(buf); rep(i,k) P = P*10 + (buf[i]-'0'); if(P >= MD || k >= 12){ writerLn(0); continue; } if(P > (CC+1)/2){ writerLn(0); continue; } C = (C+1-P+MD) % MD; if(C < P){ writerLn(0); continue; } res = get_fact(C) * get_inv(get_fact(C-P), MD) % MD; writerLn(res); } return 0; }