結果
問題 |
No.10 +か×か
|
ユーザー |
![]() |
提出日時 | 2015-07-14 01:48:34 |
言語 | C90 (gcc 12.3.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 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 WA * 3 |
コンパイルメッセージ
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; }