結果
問題 |
No.10 +か×か
|
ユーザー |
|
提出日時 | 2014-11-17 16:03:56 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 502 bytes |
コンパイル時間 | 778 ms |
コンパイル使用メモリ | 52,864 KB |
実行使用メモリ | 8,576 KB |
最終ジャッジ日時 | 2025-01-02 16:38:40 |
合計ジャッジ時間 | 13,809 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 TLE * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%d%d",&n,&total); | ~~~~~^~~~~~~~~~~~~~~~~~ main.cpp:23:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 23 | for(int i=0;i<n;i++)scanf("%d",&v[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <string> #include <vector> #include <cstdio> #include <cstdlib> using namespace std; void dfs(int total,int cur,vector<int> &v,string s){ if(s.size()==v.size()-1){ if(cur==total){ puts(s.c_str()); exit(0); } return; } if(cur>total)return; dfs(total,cur+v[s.size()+1],v,s+'+'); dfs(total,cur*v[s.size()+1],v,s+'*'); } int main(){ int n,total; scanf("%d%d",&n,&total); vector<int>v(n); for(int i=0;i<n;i++)scanf("%d",&v[i]); dfs(total,v[0],v,""); }