結果
問題 | No.528 10^9と10^9+7と回文 |
ユーザー | 👑 testestest |
提出日時 | 2017-06-10 00:08:12 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 377 bytes |
コンパイル時間 | 258 ms |
コンパイル使用メモリ | 30,592 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-23 18:30:09 |
合計ジャッジ時間 | 1,175 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,812 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 1 ms
6,940 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 1 ms
6,944 KB |
testcase_09 | AC | 1 ms
6,940 KB |
testcase_10 | AC | 3 ms
6,940 KB |
testcase_11 | AC | 3 ms
6,940 KB |
testcase_12 | AC | 3 ms
6,944 KB |
testcase_13 | AC | 3 ms
6,940 KB |
testcase_14 | AC | 3 ms
6,944 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,944 KB |
testcase_18 | AC | 3 ms
6,944 KB |
testcase_19 | AC | 1 ms
6,940 KB |
testcase_20 | AC | 3 ms
6,940 KB |
testcase_21 | AC | 2 ms
6,948 KB |
testcase_22 | AC | 1 ms
6,944 KB |
testcase_23 | AC | 1 ms
6,944 KB |
testcase_24 | AC | 1 ms
6,944 KB |
testcase_25 | AC | 1 ms
6,944 KB |
testcase_26 | AC | 3 ms
6,944 KB |
testcase_27 | AC | 3 ms
6,944 KB |
コンパイルメッセージ
main.c:2:1: warning: data definition has no type or storage class 2 | M=1e9,k; | ^ main.c:2:1: warning: type defaults to 'int' in declaration of 'M' [-Wimplicit-int] main.c:2:7: warning: type defaults to 'int' in declaration of 'k' [-Wimplicit-int] 2 | M=1e9,k; | ^ main.c: In function 'p': main.c:3:6: warning: type of 'a' defaults to 'int' [-Wimplicit-int] 3 | long p(a,n,m){return n?p(1L*a*a%m,n/2,m)*(n&1?a:1)%m:1;} | ^ main.c:3:6: warning: type of 'n' defaults to 'int' [-Wimplicit-int] main.c:3:6: warning: type of 'm' defaults to 'int' [-Wimplicit-int] main.c: At top level: main.c:4:1: warning: return type defaults to 'int' [-Wimplicit-int] 4 | g(){ | ^ main.c:11:1: warning: return type defaults to 'int' [-Wimplicit-int] 11 | f(m){ | ^ main.c: In function 'f': main.c:11:1: warning: type of 'm' defaults to 'int' [-Wimplicit-int] main.c: At top level: main.c:16:1: warning: return type defaults to 'int' [-Wimplicit-int] 16 | main(){ | ^~~~ main.c: In function 'main': main.c:17:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 17 | scanf("%s",num); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | char num[100010]; main.c:17:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 17 | scanf("%s",num); | ^~~~~ main.c:17:9: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:18:11: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration] 18 | k=strlen(num); | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'strlen' +++ |+#include <string.h> 1 | char num[100010]; main.c:18:11: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch] 18 | k=s
ソースコード
char num[100010]; M=1e9,k; long p(a,n,m){return n?p(1L*a*a%m,n/2,m)*(n&1?a:1)%m:1;} g(){ for(int l=(k-1)/2,r=k/2;l>=0;l--,r++){ if(num[l]<num[r])return 0; if(num[l]>num[r])return 1; } return 0; } f(m){ long s=0; for(int i=0;i<k-k/2;i++)s=(s*10+num[i]-'0')%m; return(p(10,k/2,m)+s+~g()+m)%m; } main(){ scanf("%s",num); k=strlen(num); printf("%d\n%d",f(M),f(M+7)); }