結果
問題 | No.1419 Power Moves |
ユーザー | tails |
提出日時 | 2021-03-11 14:21:33 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,934 bytes |
コンパイル時間 | 1,216 ms |
コンパイル使用メモリ | 33,408 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-13 02:47:27 |
合計ジャッジ時間 | 2,313 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,820 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 1 ms
6,816 KB |
testcase_03 | AC | 1 ms
6,816 KB |
testcase_04 | AC | 1 ms
6,820 KB |
testcase_05 | AC | 1 ms
6,816 KB |
testcase_06 | AC | 0 ms
6,816 KB |
testcase_07 | AC | 1 ms
6,816 KB |
testcase_08 | AC | 1 ms
6,816 KB |
testcase_09 | AC | 1 ms
6,816 KB |
testcase_10 | AC | 1 ms
6,816 KB |
testcase_11 | AC | 1 ms
6,816 KB |
testcase_12 | AC | 2 ms
6,820 KB |
testcase_13 | AC | 2 ms
6,820 KB |
testcase_14 | AC | 1 ms
6,816 KB |
testcase_15 | AC | 2 ms
6,820 KB |
testcase_16 | AC | 1 ms
6,816 KB |
testcase_17 | AC | 1 ms
6,816 KB |
testcase_18 | AC | 1 ms
6,820 KB |
testcase_19 | AC | 1 ms
6,816 KB |
testcase_20 | AC | 2 ms
6,820 KB |
testcase_21 | AC | 2 ms
6,816 KB |
testcase_22 | AC | 2 ms
6,820 KB |
testcase_23 | AC | 2 ms
6,816 KB |
testcase_24 | AC | 1 ms
6,816 KB |
testcase_25 | AC | 2 ms
6,816 KB |
testcase_26 | AC | 2 ms
6,820 KB |
testcase_27 | AC | 1 ms
6,816 KB |
testcase_28 | AC | 1 ms
6,816 KB |
testcase_29 | AC | 2 ms
6,820 KB |
testcase_30 | AC | 3 ms
6,820 KB |
testcase_31 | AC | 2 ms
6,820 KB |
testcase_32 | AC | 2 ms
6,816 KB |
testcase_33 | AC | 2 ms
6,820 KB |
コンパイルメッセージ
main.c: In function 'f2': main.c:38:7: warning: type of 'v0' defaults to 'int' [-Wimplicit-int] 38 | long* f2(wp,v0,v1,i,e) | ^~ main.c:38:7: warning: type of 'v1' defaults to 'int' [-Wimplicit-int] main.c:38:7: warning: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:38:7: warning: type of 'e' defaults to 'int' [-Wimplicit-int] main.c:42:9: warning: implicit declaration of function 'sprintf' [-Wimplicit-function-declaration] 42 | sprintf(b,"%11d\n%11d\n",v0,v1); | ^~~~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'sprintf' +++ |+#include <stdio.h> 1 | #pragma GCC optimize("Ofast") main.c:42:9: warning: incompatible implicit declaration of built-in function 'sprintf' [-Wbuiltin-declaration-mismatch] 42 | sprintf(b,"%11d\n%11d\n",v0,v1); | ^~~~~~~ main.c:42:9: note: include '<stdio.h>' or provide a declaration of 'sprintf' main.c:42:17: warning: passing argument 1 of 'sprintf' from incompatible pointer type [-Wincompatible-pointer-types] 42 | sprintf(b,"%11d\n%11d\n",v0,v1); | ^ | | | long int * main.c:42:17: note: expected 'char *' but argument is of type 'long int *' main.c: In function 'f1': main.c:54:7: warning: type of 'v' defaults to 'int' [-Wimplicit-int] 54 | long* f1(wp,v,i,e) | ^~ main.c:54:7: warning: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:54:7: warning: type of 'e' defaults to 'int' [-Wimplicit-int] main.c:58:9: warning: incompatible implicit declaration of built-in function 'sprintf' [-Wbuiltin-declaration-mismatch] 58 | sprintf(b," 0\n%11d\n",v); | ^~~~~~~ main.c:58:9: note: include '<stdio.h>' or provide a declaration of 'sprintf' main.c:58:17: warning: passing argument 1 of 'sprintf' from incompatible pointer type [-Wincompatible-pointer-types] 58 | sprintf(b," 0\n%11d\n",v); | ^ |
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") char*mmap(); #define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} long wbuf[1<<25]; #define MD 1000000007 long modpow(long a, long b, long m){ long r=1; while(b){ if(b&1){ r=r*a%m; } b>>=1; a=a*a%m; } return r; } int inverse(int a){ int b=MD; int u=1; int v=0; while(b){ int q=a/b,t; t=b, b=a-q*b, a=t; t=v, v=u-q*v, u=t; } if(u<0){ u+=MD; } return u; } long* f2(wp,v0,v1,i,e) long*wp; { long b[3]; sprintf(b,"%11d\n%11d\n",v0,v1); long b0=b[0]; long b1=b[1]; long b2=b[2]; for(i+=i&1;i<e;i+=2){ *wp++=b0; *wp++=b1; *wp++=b2; } return wp; } long* f1(wp,v,i,e) long*wp; { long b[2]; sprintf(b," 0\n%11d\n",v); long b0=b[0]; long b1=b[1]; for(i+=i&1;i<e;i+=2){ *wp++=b0; *wp++=b1; } return wp; } main(){ char*rp=mmap(0l,1l<<28,1,2,0,0ll); RD(n); RD(k); int r=modpow(2,k-1,n); int q=(modpow(2,k-1,MD)-r+MD)%MD*inverse(n)*(n&1?2:4)%MD; int d=modpow((MD+1)/2,k,MD); q=1l*q*d%MD; r*=2; long*wp=wbuf; if(n&1){ if(n<r){ r-=n; q=(q+d)%MD; int q0=q; int q1=(q+d)%MD; if(r<n-r){ wp=f2(wp,q1,q0,0,r); wp=f2(wp,q0,q0,r,n-r); wp=f2(wp,q0,q1,n-r,n); }else{ wp=f2(wp,q1,q0,0,n-r); wp=f2(wp,q1,q1,n-r,r); wp=f2(wp,q0,q1,r,n); } }else{ int q0=q; int q1=(q+d)%MD; if(r<n-r){ wp=f2(wp,q0,q1,0,r); wp=f2(wp,q0,q0,r,n-r); wp=f2(wp,q1,q0,n-r,n); }else{ wp=f2(wp,q0,q1,0,n-r); wp=f2(wp,q1,q1,n-r,r); wp=f2(wp,q1,q0,r,n); } } write(1,wbuf,(char*)wp-(char*)wbuf-12); }else{ if(n<r){ r-=n; q=(q+d)%MD; q=(q+d)%MD; } int q0=q; int q1=(q0+d)%MD; int q2=(q1+d)%MD; if(r<n-r){ wp=f1(wp,q1,0,r); wp=f1(wp,q0,r,n-r); wp=f1(wp,q1,n-r,n); }else{ wp=f1(wp,q1,0,n-r); wp=f1(wp,q2,n-r,r); wp=f1(wp,q1,r,n); } write(1,wbuf,(char*)wp-(char*)wbuf); } _exit(0); }