結果
問題 | No.634 硬貨の枚数1 |
ユーザー | tails |
提出日時 | 2018-01-19 21:41:03 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 323 bytes |
コンパイル時間 | 264 ms |
コンパイル使用メモリ | 28,800 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-25 18:39:57 |
合計ジャッジ時間 | 2,699 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 75 |
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class 1 | n;i;j;s;t; | ^ main.c:1:1: warning: type defaults to 'int' in declaration of 'n' [-Wimplicit-int] main.c:1:3: warning: data definition has no type or storage class 1 | n;i;j;s;t; | ^ main.c:1:3: warning: type defaults to 'int' in declaration of 'i' [-Wimplicit-int] main.c:1:5: warning: data definition has no type or storage class 1 | n;i;j;s;t; | ^ main.c:1:5: warning: type defaults to 'int' in declaration of 'j' [-Wimplicit-int] main.c:1:7: warning: data definition has no type or storage class 1 | n;i;j;s;t; | ^ main.c:1:7: warning: type defaults to 'int' in declaration of 's' [-Wimplicit-int] main.c:1:9: warning: data definition has no type or storage class 1 | n;i;j;s;t; | ^ main.c:1:9: warning: type defaults to 'int' in declaration of 't' [-Wimplicit-int] main.c:2:1: warning: return type defaults to 'int' [-Wimplicit-int] 2 | main(){ | ^~~~ main.c: In function 'main': main.c:3:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 3 | scanf("%d",&n); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | n;i;j;s;t; main.c:3:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 3 | scanf("%d",&n); | ^~~~~ main.c:3:9: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:7:25: warning: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 7 | puts("1"); | ^~~~ main.c:7:25: note: include '<stdio.h>' or provide a declaration of 'puts' main.c:8:25: warning: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 8 | exit(0); | ^~~~ main.c:1:1: note: include
ソースコード
n;i;j;s;t; main(){ scanf("%d",&n); for(i=0;;++i){ s=i*(i+1)/2; if(s==n){ puts("1"); exit(0); } if(s>n){ break; } } for(i=0;;++i){ s=i*(i+1)/2; for(j=i;;++j){ t=s+j*(j+1)/2; if(t==n){ puts("2"); exit(0); } if(t>n){ break; } } if(s>n){ break; } } puts("3"); }