結果

問題 No.510 二次漸化式
ユーザー DameningenDameningen
提出日時 2017-04-29 00:10:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,706 bytes
コンパイル時間 720 ms
コンパイル使用メモリ 88,504 KB
実行使用メモリ 6,148 KB
最終ジャッジ日時 2023-10-11 20:42:50
合計ジャッジ時間 47,525 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 357 ms
4,352 KB
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 AC 1,732 ms
5,940 KB
testcase_17 AC 1,704 ms
5,824 KB
testcase_18 AC 1,706 ms
5,764 KB
testcase_19 AC 1,710 ms
5,804 KB
testcase_20 AC 1,708 ms
5,816 KB
testcase_21 AC 1,709 ms
5,804 KB
testcase_22 AC 1,699 ms
5,716 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 AC 15 ms
5,464 KB
testcase_32 AC 15 ms
5,516 KB
testcase_33 AC 16 ms
5,864 KB
testcase_34 TLE -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<cassert>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAX_N = 100000, MAX_Q = 20000, MOD = 1e9 + 7;


int main()
{
    int n, q;
    static ll a[MAX_N+1], b[MAX_N+1];
    static int x[MAX_N+1], y[MAX_N+1];
    a[0] = 1; b[0] = 1;
    
    cin >> n >> q;
    
    static char query[MAX_Q];
    static int i[MAX_Q], v[MAX_Q];
    
    
    rep(s, q) {
        cin >> query[s];
        if (query[s] == 'x') {
            cin >> i[s] >> v[s];
        } else if (query[s] == 'y') {
            cin >> i[s] >> v[s];
        } else {
            cin >> i[s];
        }
    }
    
    
    
    rep(s, q) {
        
        if (query[s] == 'x') {
            x[i[s]] = v[s];
        } else if (query[s] == 'y') {
            y[i[s]] = v[s];
        } else {
            
            if (i[s] == 0) {
                cout << 1 << endl;
            }
            
            reps(j, 1, i[s]+1) {
                a[j] = (((x[j-1] * b[j-1]) % MOD) * b[j-1] + a[j-1]) % MOD;
                b[j] = (y[j-1] * b[j-1] + 1) % MOD;
            }
            
            cout << a[i[s]] << endl;
        }
    }
    
    return 0;
}
0