結果
問題 | No.10 +か×か |
ユーザー |
![]() |
提出日時 | 2015-07-14 07:52:45 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 11 ms / 5,000 ms |
コード長 | 667 bytes |
コンパイル時間 | 255 ms |
コンパイル使用メモリ | 22,144 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2024-12-14 15:30:00 |
合計ジャッジ時間 | 731 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:10:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d", &n); | ^~~~~~~~~~~~~~~ main.c:11:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d", &total); | ^~~~~~~~~~~~~~~~~~~ main.c:14:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%d", &a[i]); | ^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> char dp[55][100100]; int main(void){ int p; int i,j,n,total; int a[55]; scanf("%d", &n); scanf("%d", &total); for(i=0;i<n;i++){ scanf("%d", &a[i]); } dp[n][total] = 1; for(i=n-1;i>=0;i--){ for(j=0;j<total+1;j++){ int tmp = j+a[i]; dp[i][j] = 0; if( tmp <= total && dp[i+1][tmp]){ dp[i][j] = 1; } tmp = j*a[i]; if( tmp <= total && dp[i+1][tmp]){ dp[i][j] = 1; } } } p = a[0]; for(i=1;i<n;i++){ if( (p+a[i]) <= total && dp[i+1][p+a[i]] ){ p+=a[i]; printf("+"); continue; } if( (p*a[i]) <= total && dp[i+1][p*a[i]] ){ p*=a[i]; printf("*"); continue; } } printf("\n"); return 0; }