結果
問題 | No.510 二次漸化式 |
ユーザー |
![]() |
提出日時 | 2017-04-29 00:14:34 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2,274 ms / 3,000 ms |
コード長 | 767 bytes |
コンパイル時間 | 247 ms |
コンパイル使用メモリ | 23,680 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 19:33:53 |
合計ジャッジ時間 | 23,591 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:42:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 42 | scanf("%d%d\n", &n, &q); | ~~~~~^~~~~~~~~~~~~~~~~~ main.cpp:48:22: warning: ignoring return value of ‘char* fgets(char*, int, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 48 | 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 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); } last_update=i; printf("%lld\n", a[i]); } void min_u(int &min, int v) { if(min>v) min=v; } 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; }