結果

問題 No.265 数学のテスト
ユーザー mamekinmamekin
提出日時 2016-02-06 20:49:23
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,424 bytes
コンパイル時間 1,157 ms
コンパイル使用メモリ 93,000 KB
実行使用メモリ 5,780 KB
最終ジャッジ日時 2023-10-21 19:32:20
合計ジャッジ時間 1,896 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,780 KB
testcase_01 AC 4 ms
4,780 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int n, d;
string s;

void solve(int& i, vector<long long>& a)
{
    a.assign(d+1, 0);

    long long coefficient = 0;
    int degree = 0;

    for(;;){
        if(i == n || s[i] == '}'){
            a[degree] += coefficient;
            return;
        }
        if(s[i] == 'd'){
            i+= 2;
            vector<long long> b;
            solve(i, b);
            for(int j=1; j<=d; ++j)
                a[j-1] += b[j] * j;
        }
        else if(s[i] == '+'){
            a[degree] += coefficient;
            coefficient = 0;
            degree = 0;
        }
        else if(s[i] == 'x'){
            if(coefficient == 0)
                coefficient = 1;
            ++ degree;
        }
        else if(isdigit(s[i])){
            coefficient *= 10;
            coefficient += s[i] - '0';
        }
        ++ i;
    }
}

int main()
{
    cin >> n >> d >> s;

    int i = 0;
    vector<long long> a;
    solve(i, a);

    cout << a[0];
    for(int j=1; j<=d; ++j)
        cout << ' ' << a[j];
    cout << endl;

    return 0;
}
0