Submission #08458
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include<stdio.h> int dfs( int x, int sum); int n,k; int data[25]; int flag[25]; int a; int main(){ int ans; int i,j; scanf ( "%d %d" ,&n,&k); for (i=0;i<n;i++){ scanf ( "%d" ,&data[i]); } ans=dfs(0,0); if (ans){ printf ( "OK\n" ); } else { printf ( "NG\n" ); } return 0; } int dfs( int x, int sum){ if (sum==k) return 1; if (x==n) return 0; int rec=0; rec+=dfs(x+1,sum+data[x]); rec+=dfs(x+1,sum); return rec; } |
ステータス
項目 | データ |
---|---|
問題 | 0064 - 足し算できる? |
ユーザー名 | ei1630 |
投稿日時 | 2016-08-10 13:30:41 |
言語 | C++11 |
状態 | Accepted |
得点 | 5 |
ソースコード長 | 464 Byte |
最大実行時間 | 16 ms |
最大メモリ使用量 | 576 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 5 / 5 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
AddInput1.txt | AC | 14 ms | 476 KB |
1
|
AddInput2.txt | AC | 9 ms | 460 KB |
1
|
AddInput3.txt | AC | 10 ms | 576 KB |
1
|
AddInput4.txt | AC | 12 ms | 564 KB |
1
|
AddInput5.txt | AC | 14 ms | 548 KB |
1
|
AddInput6.txt | AC | 16 ms | 532 KB |
1
|