結果
問題 | No.265 数学のテスト |
ユーザー |
![]() |
提出日時 | 2015-08-07 22:48:16 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 1,255 bytes |
コンパイル時間 | 712 ms |
コンパイル使用メモリ | 67,788 KB |
実行使用メモリ | 5,504 KB |
最終ジャッジ日時 | 2024-11-24 11:17:14 |
合計ジャッジ時間 | 1,490 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:69:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 69 | scanf("%s", s); | ~~~~~^~~~~~~~~ main.cpp: In function ‘int getInt()’: main.cpp:9:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | inline int getInt(){ int s; scanf("%d", &s); return s; } | ~~~~~^~~~~~~~~~
ソースコード
typedef long long ll;#define REP(i,n) for(int i=0; i<(int)(n); i++)#include <map>#include <iostream>#include <queue>#include <cstdio>inline int getInt(){ int s; scanf("%d", &s); return s; }#include <set>using namespace std;char s[50000 + 100];int n, d;pair<int, ll> parseTerm(int &pos){int x = 0;ll i = 1;for(; pos < n; pos++){if(s[pos] == 'x'){x++;}else if(isdigit(s[pos])){i *= s[pos] - '0';}else if(s[pos] == '*'){}else{break;}}return make_pair(x, i);}vector<ll> parse(int &pos){vector<ll> ret(d + 1);while(pos < n){const char c = s[pos];// printf("%d: %c\n", pos, c);if(c == 'd'){pos += 2; // d{const vector<ll> tmp = parse(pos);pos += 1; // }REP(i,d) ret[i] += (i + 1) * tmp[i + 1];}else if(isdigit(c) || c == 'x'){const pair<int, ll> tmp = parseTerm(pos);ret[tmp.first] += tmp.second;}else{break;}if(pos < n && s[pos] == '+') pos++;}return ret;}vector<ll> parse(){int pos = 0;return parse(pos);}int main(){n = getInt();d = getInt();scanf("%s", s);const vector<ll> ret = parse();REP(i,d+1) printf("%lld ", ret[i]); puts("");return 0;}