結果
問題 |
No.510 二次漸化式
|
ユーザー |
|
提出日時 | 2025-02-23 17:10:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,482 ms / 3,000 ms |
コード長 | 752 bytes |
コンパイル時間 | 1,621 ms |
コンパイル使用メモリ | 162,140 KB |
実行使用メモリ | 8,408 KB |
最終ジャッジ日時 | 2025-02-23 17:10:23 |
合計ジャッジ時間 | 15,461 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 34 |
ソースコード
#include<bits/stdc++.h> #define int long long #define MOD 1000000007 #define MAXN 1000005 using namespace std; inline int read(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ x=x*10+ch-48; ch=getchar(); } return x*f; } int n,q; int x[MAXN]; int y[MAXN]; signed main(){ // freopen("generator.in","r",stdin); // freopen("generator.out","w",stdout); n=read();q=read(); while(q--){ char s;int k; cin>>s; k=read(); if(s=='x') x[k]=read(); else if(s=='y') y[k]=read(); else if(s=='a'){ int a=1,b=1; for(int i=0;i<k;i++){ if(x[i]) (a+=x[i]*b%MOD*b)%=MOD; if(y[i]) b=(b*y[i]+1)%MOD; else b=1; } printf("%lld\n",a); } } return 0; }