結果
問題 |
No.265 数学のテスト
|
ユーザー |
|
提出日時 | 2019-09-27 15:56:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,139 bytes |
コンパイル時間 | 594 ms |
コンパイル使用メモリ | 70,744 KB |
実行使用メモリ | 814,720 KB |
最終ジャッジ日時 | 2024-09-24 06:58:33 |
合計ジャッジ時間 | 3,795 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 4 |
other | MLE * 1 -- * 31 |
ソースコード
#include<iostream> #include<vector> using namespace std; vector<int> f(int d, int &pos, const string s){ vector<int> ret(d+1, 0); if(s[pos] == 'd'){ pos++; // d pos++; // { vector<int> tmp(d+1, 0); while(s[pos] != '}'){ if(s[pos] == '+') pos++; vector<int> v = f(d, pos, s); for(int i = 0; i <= d; i++) tmp[i] += v[i]; } pos++; // } for(int i = 0; i < d; i++) ret[i] = (i+1)*tmp[i+1]; }else{ int num = 1, deg = 0; if(isdigit(s[pos])){ num *= (s[pos]-'0'); }else{ deg++; } pos++; while(pos < s.length() && s[pos] == '*'){ pos += 2; deg++; } ret[deg] = num; } return ret; } int main(){ int n, d; string s; cin >> n >> d >> s; int pos = 0; vector<int> v = f(d, pos, s); while(pos < s.length()){ pos++; vector<int> tmp = f(d, pos, s); for(int i = 0; i <= d; i++) v[i] += tmp[i]; } for(int i = 0; i <= d; i++) cout << v[i] << " \n"[i==d]; return 0; }