結果

問題 No.510 二次漸化式
ユーザー legendcn
提出日時 2025-04-12 00:59:47
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2,065 ms / 3,000 ms
コード長 800 bytes
コンパイル時間 2,117 ms
コンパイル使用メモリ 192,296 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-12 01:00:07
合計ジャッジ時間 17,601 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:11: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |     scanf ("%lld%lld", &n, &q);
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp:19:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |         char op; int k; scanf (" %c%lld", &op, &k);
      |                         ~~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp:20:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |                 if (op == 'x') scanf ("%lld", &x[k]);
      |                                ~~~~~~^~~~~~~~~~~~~~~
main.cpp:21:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |                 else if (op == 'y') scanf ("%lld", &y[k]);
      |                                     ~~~~~~^~~~~~~~~~~~~~~

ソースコード

diff #

# include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
# define int long long
# define lc u << 1
# define rc u << 1 | 1
# define fi first
# define se second
const int N = 1000005, mod = 1e9 + 7;

int n, q;
int x[N], y[N];
signed main ()
{
	// freopen ("generator.in", "r", stdin); freopen ("generator.out", "w", stdout);
    scanf ("%lld%lld", &n, &q);
    while (q -- )
    {
        char op; int k; scanf (" %c%lld", &op, &k);
		if (op == 'x') scanf ("%lld", &x[k]);
		else if (op == 'y') scanf ("%lld", &y[k]);
		else if (op == 'a')
        {
			int a = 1, b = 1;
            for (int i = 0; i < k; i ++ )
            {
				if (x[i]) a = (a + x[i] * b % mod * b % mod) % mod;
				if (y[i]) b = (b * y[i] + 1) % mod;
				else b = 1;
			}
			printf ("%lld\n", a);
		}
	}
	return 0;
}
0