結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
mh72012246
|
| 提出日時 | 2016-11-08 13:25:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,186 bytes |
| コンパイル時間 | 1,434 ms |
| コンパイル使用メモリ | 96,420 KB |
| 実行使用メモリ | 814,848 KB |
| 最終ジャッジ日時 | 2024-11-25 04:48:08 |
| 合計ジャッジ時間 | 8,095 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 WA * 3 MLE * 2 |
ソースコード
#include <iostream>
#include <cmath>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <sstream> // istringstream
#include <algorithm> // sort
#include <utility> // pair
#include <cfloat> // DBL_MAX
typedef long long ll;
using namespace std;
// const int maxN = 200000;
// bool ps[maxN-1];
int main(){
ll N, total; // [50, 100,000]
cin >> N >> total;
vector<int> As(N);
for(int i=0; i<N; i++){
cin >> As[i];
}
// main
queue<pair<int,string> > fomulas;
fomulas.push(make_pair(total, ""));
for(int i=N-1; i>0; i--){
queue<pair<int,string> > next;
while(!fomulas.empty()){
// +
if(fomulas.front().first >= As[i]){
next.push(make_pair(fomulas.front().first-As[i],
"+"+fomulas.front().second));
}
// *
if(fomulas.front().first%As[i] == 0){
next.push(make_pair(fomulas.front().first/As[i],
"*"+fomulas.front().second));
}
fomulas.pop();
}
fomulas = next;
}
// output
while(fomulas.front().first!=As[0]){ fomulas.pop(); }
cout << fomulas.front().second << endl;
return 0;
}
mh72012246