結果
問題 | No.1419 Power Moves |
ユーザー | tails |
提出日時 | 2021-03-11 12:57:51 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 2,006 bytes |
コンパイル時間 | 377 ms |
コンパイル使用メモリ | 33,536 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 01:50:59 |
合計ジャッジ時間 | 2,630 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 1 ms
5,248 KB |
testcase_05 | AC | 1 ms
5,248 KB |
testcase_06 | AC | 1 ms
5,248 KB |
testcase_07 | AC | 1 ms
5,248 KB |
testcase_08 | AC | 1 ms
5,248 KB |
testcase_09 | AC | 2 ms
5,248 KB |
testcase_10 | AC | 1 ms
5,248 KB |
testcase_11 | AC | 1 ms
5,248 KB |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | AC | 2 ms
5,248 KB |
testcase_14 | AC | 1 ms
5,248 KB |
testcase_15 | AC | 1 ms
5,248 KB |
testcase_16 | AC | 2 ms
5,248 KB |
testcase_17 | AC | 1 ms
5,248 KB |
testcase_18 | AC | 1 ms
5,248 KB |
testcase_19 | AC | 1 ms
5,248 KB |
testcase_20 | AC | 2 ms
5,248 KB |
testcase_21 | AC | 2 ms
5,248 KB |
testcase_22 | AC | 2 ms
5,248 KB |
testcase_23 | AC | 2 ms
5,248 KB |
testcase_24 | AC | 1 ms
5,248 KB |
testcase_25 | AC | 2 ms
5,248 KB |
testcase_26 | AC | 2 ms
5,248 KB |
testcase_27 | AC | 2 ms
5,248 KB |
testcase_28 | AC | 2 ms
5,248 KB |
testcase_29 | AC | 2 ms
5,248 KB |
testcase_30 | AC | 3 ms
5,248 KB |
testcase_31 | AC | 2 ms
5,248 KB |
testcase_32 | AC | 2 ms
5,248 KB |
testcase_33 | AC | 1 ms
5,248 KB |
コンパイルメッセージ
main.c: In function 'f2': main.c:38:6: warning: type of 'v0' defaults to 'int' [-Wimplicit-int] 38 | int* f2(wp,v0,v1,i,e) | ^~ main.c:38:6: warning: type of 'v1' defaults to 'int' [-Wimplicit-int] main.c:38:6: warning: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:38:6: 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); | ^ | | | int * main.c:42:17: note: expected 'char *' but argument is of type 'int *' main.c: In function 'f1': main.c:60:6: warning: type of 'v' defaults to 'int' [-Wimplicit-int] 60 | int* f1(wp,v,i,e) | ^~ main.c:60:6: warning: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:60:6: warning: type of 'e' defaults to 'int' [-Wimplicit-int] main.c:64:9: warning: incompatible implicit declaration of built-in function 'sprintf' [-Wbuiltin-declaration-mismatch] 64 | sprintf(b,"%11d\n",v); | ^~~~~~~ main.c:64:9: note: include '<stdio.h>' or provide a declaration of 'sprintf' main.c:64:17: warning: passing argument 1 of 'sprintf' from incompatible pointer type [-Wincompatible-pointer-types] 64 | sprintf(b,"%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;} int wbuf[1<<26]; #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; } int* f2(wp,v0,v1,i,e) int*wp; { int b[6]; sprintf(b,"%11d\n%11d\n",v0,v1); int b0=b[0]; int b1=b[1]; int b2=b[2]; int b3=b[3]; int b4=b[4]; int b5=b[5]; for(i+=i&1;i<e;i+=2){ *wp++=b0; *wp++=b1; *wp++=b2; *wp++=b3; *wp++=b4; *wp++=b5; } return wp; } int* f1(wp,v,i,e) int*wp; { int b[3]; sprintf(b,"%11d\n",v); int b0=b[0]; int b1=b[1]; int b2=b[2]; for(i+=i&1;i<e;i+=2){ *wp++=0x0a302020; *wp++=b0; *wp++=b1; *wp++=b2; } 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; int*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); } } wp-=3; }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,(wp-wbuf)*sizeof*wbuf); _exit(0); }