結果

問題 No.435 占い(Extra)
ユーザー testestesttestestest
提出日時 2016-10-15 04:29:47
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 21,760 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-08 11:58:49
合計ジャッジ時間 3,842 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 0 ms
5,248 KB
testcase_04 AC 0 ms
5,248 KB
testcase_05 AC 0 ms
5,248 KB
testcase_06 AC 1 ms
5,248 KB
testcase_07 AC 0 ms
5,248 KB
testcase_08 AC 1 ms
5,248 KB
testcase_09 AC 1 ms
5,248 KB
testcase_10 AC 2 ms
5,248 KB
testcase_11 AC 2 ms
5,248 KB
testcase_12 AC 15 ms
5,248 KB
testcase_13 AC 15 ms
5,248 KB
testcase_14 AC 15 ms
5,248 KB
testcase_15 AC 16 ms
5,248 KB
testcase_16 AC 21 ms
5,248 KB
testcase_17 AC 75 ms
5,248 KB
testcase_18 AC 14 ms
5,248 KB
testcase_19 AC 15 ms
5,248 KB
testcase_20 AC 146 ms
5,248 KB
testcase_21 AC 141 ms
5,248 KB
testcase_22 AC 147 ms
5,248 KB
testcase_23 AC 146 ms
5,248 KB
testcase_24 AC 146 ms
5,248 KB
testcase_25 AC 205 ms
5,248 KB
testcase_26 AC 144 ms
5,248 KB
testcase_27 AC 140 ms
5,248 KB
testcase_28 AC 0 ms
5,248 KB
testcase_29 AC 141 ms
5,248 KB
testcase_30 AC 146 ms
5,248 KB
testcase_31 AC 112 ms
5,248 KB
testcase_32 AC 123 ms
5,248 KB
testcase_33 AC 145 ms
5,248 KB
testcase_34 AC 170 ms
5,248 KB
testcase_35 AC 142 ms
5,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
    1 | x,a,b,m,n,i,t,ans,c,c3;
      | ^
main.c:1:1: warning: type defaults to ‘int’ in declaration of ‘x’ [-Wimplicit-int]
main.c:1:3: warning: type defaults to ‘int’ in declaration of ‘a’ [-Wimplicit-int]
    1 | x,a,b,m,n,i,t,ans,c,c3;
      |   ^
main.c:1:5: warning: type defaults to ‘int’ in declaration of ‘b’ [-Wimplicit-int]
    1 | x,a,b,m,n,i,t,ans,c,c3;
      |     ^
main.c:1:7: warning: type defaults to ‘int’ in declaration of ‘m’ [-Wimplicit-int]
    1 | x,a,b,m,n,i,t,ans,c,c3;
      |       ^
main.c:1:9: warning: type defaults to ‘int’ in declaration of ‘n’ [-Wimplicit-int]
    1 | x,a,b,m,n,i,t,ans,c,c3;
      |         ^
main.c:1:11: warning: type defaults to ‘int’ in declaration of ‘i’ [-Wimplicit-int]
    1 | x,a,b,m,n,i,t,ans,c,c3;
      |           ^
main.c:1:13: warning: type defaults to ‘int’ in declaration of ‘t’ [-Wimplicit-int]
    1 | x,a,b,m,n,i,t,ans,c,c3;
      |             ^
main.c:1:15: warning: type defaults to ‘int’ in declaration of ‘ans’ [-Wimplicit-int]
    1 | x,a,b,m,n,i,t,ans,c,c3;
      |               ^~~
main.c:1:19: warning: type defaults to ‘int’ in declaration of ‘c’ [-Wimplicit-int]
    1 | x,a,b,m,n,i,t,ans,c,c3;
      |                   ^
main.c:1:21: warning: type defaults to ‘int’ in declaration of ‘c3’ [-Wimplicit-int]
    1 | x,a,b,m,n,i,t,ans,c,c3;
      |                     ^~
main.c:2:1: warning: data definition has no type or storage class
    2 | inv9[]={0,1,5,0,7,2,0,4,8};
      | ^~~~
main.c:2:1: warning: type defaults to ‘int’ in declaration of ‘inv9’ [-Wimplicit-int]
main.c:3:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    3 | f3(n){int i=0;for(;n&&n%3==0;n/=3)i++;return i;}
      | ^~
main.c: In function ‘f3’:
main.c:3:1: warning: type of ‘n’ defaults to ‘int’ [-Wimplicit-int]
main.c: At top level:
main.c:4:1: warning: r

ソースコード

diff #

x,a,b,m,n,i,t,ans,c,c3;
inv9[]={0,1,5,0,7,2,0,4,8};
f3(n){int i=0;for(;n&&n%3==0;n/=3)i++;return i;}
g3(n){for(;n&&n%3==0;n/=3);return n;}
main(){
	for(gets(&i);~scanf("%d%d%d%d%d",&n,&x,&a,&b,&m);){
		n--;
		t=ans=c3=0,c=1;
		for(i=0;i<=n;i++){
			t+=x%10;
			ans+=c*(c3?c3==1?3:0:1)*(x%10)%9;
			c3+=f3(n-i)-f3(i+1);
			c=(c*g3(n-i)*inv9[g3(i+1)%9])%9;
			x=((x^a)+b)%m;
		}
		printf("%d\n",ans%9?:t?9:0);
	}
}
0