結果
問題 |
No.510 二次漸化式
|
ユーザー |
![]() |
提出日時 | 2017-04-29 01:21:41 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1,455 ms / 3,000 ms |
コード長 | 815 bytes |
コンパイル時間 | 271 ms |
コンパイル使用メモリ | 23,808 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-13 18:59:04 |
合計ジャッジ時間 | 17,789 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:48:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 48 | scanf("%d%d\n", &n, &q); | ~~~~~^~~~~~~~~~~~~~~~~~ main.cpp:54:22: warning: ignoring return value of ‘char* fgets(char*, int, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 54 | fgets(oneline, sizeof(oneline), stdin); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio> typedef long long ll; ll a[100000+1], b[100000+1], x[100000+1], y[100000+1]; int last_update; ll m(ll v) { return v%1000000007; } void min_u(int &m, int v) { if(m>v) m=v; } void max_u(int &m, int v) { if(m<v) m=v; } void solve(int i) { int j; for(j=last_update;j<i;j++) { a[j+1]=m(m(x[j]*b[j])*b[j]+a[j]); b[j+1]=m(y[j]*b[j]+1); } max_u(last_update, i); printf("%lld\n", a[i]); } int main(void) { char oneline[100], t; int i, j, v, n, q; scanf("%d%d\n", &n, &q); last_update=0; for(j=0;j<q;j++) { a[0]=b[0]=1; fgets(oneline, sizeof(oneline), stdin); sscanf(oneline, "%c%d%d", &t, &i, &v); if(t=='x') { x[i]=v; min_u(last_update, i); } if(t=='y') { y[i]=v; min_u(last_update, i); } if(t=='a') { solve(i); } } return 0; }