結果
問題 | No.10 +か×か |
ユーザー | TLwiegehtt |
提出日時 | 2015-07-14 01:48:34 |
言語 | C90 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,496 bytes |
コンパイル時間 | 197 ms |
コンパイル使用メモリ | 21,888 KB |
実行使用メモリ | 67,200 KB |
最終ジャッジ日時 | 2024-07-08 07:04:49 |
合計ジャッジ時間 | 1,043 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 0 ms
5,376 KB |
testcase_02 | AC | 0 ms
5,376 KB |
testcase_03 | WA | - |
testcase_04 | AC | 39 ms
52,480 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 19 ms
25,728 KB |
testcase_09 | AC | 7 ms
9,984 KB |
testcase_10 | AC | 0 ms
5,376 KB |
testcase_11 | AC | 0 ms
5,376 KB |
コンパイルメッセージ
main.c: In function ‘main’: main.c:21:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%d", &n); | ^~~~~~~~~~~~~~~ main.c:22:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | scanf("%d", &total); | ^~~~~~~~~~~~~~~~~~~ main.c:26:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | scanf("%d", &a[i]); | ^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <string.h> #define MOD (1050000) typedef struct{ int sum; int sympos; char sym[55]; } QUEUE; QUEUE queue[MOD]; int main(void){ int i,n,total; int a[55]; int value[55]; int start, goal; start = goal = 0; scanf("%d", &n); scanf("%d", &total); for(i=0;i<55;i++){a[i] = 0; value[i] = 0;} for(i=0;i<n;i++){ scanf("%d", &a[i]); } a[i] = total*2; queue[start].sum = a[0]; queue[start].sympos = 0; queue[start].sym[0] = '\0'; start = (start+1) % MOD; while(start != goal){ int tsum = queue[goal].sum; int tmpTsum; int tSympos = queue[goal].sympos; char tSym[52]; strcpy(tSym, queue[goal].sym); goal = (goal+1) % MOD; if(value[tSympos] == tsum){ continue; } value[tSympos] = tsum; // printf("%d\n", goal); // printf("%d %d %s\n", tsum, tSympos, tSym); if(tSympos == (n-1) ){ if(total == tsum){ printf("%s\n", tSym); break; } } tmpTsum = tsum + a[tSympos+1]; if(tmpTsum <= total){ strcpy(queue[start].sym, tSym); queue[start].sum = tmpTsum; queue[start].sympos = tSympos+1; queue[start].sym[tSympos+0] = '+'; queue[start].sym[tSympos+1] = '\0'; start = (start+1) % MOD; } tmpTsum = tsum * a[tSympos+1]; if(tmpTsum <= total){ strcpy(queue[start].sym, tSym); queue[start].sum = tmpTsum; queue[start].sympos = tSympos+1; queue[start].sym[tSympos+0] = '*'; queue[start].sym[tSympos+1] = '\0'; start = (start+1) % MOD; } } return 0; }