結果

問題 No.1810 RGB Biscuits
ユーザー polylogK
提出日時 2021-11-06 20:26:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 450 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 28,032 KB
最終ジャッジ日時 2025-01-25 14:17:55
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 TLE * 1
other AC * 4 WA * 3 TLE * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:33:26: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘i64’ {aka ‘long long int’} [-Wformat=]
   33 |                 printf("%d\n", (r + g + b) % MOD);
      |                         ~^     ~~~~~~~~~~~~~~~~~
      |                          |                 |
      |                          int               i64 {aka long long int}
      |                         %lld
main.cpp:16:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         int A, B, N; scanf("%d%d%d", &A, &B, &N);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:20:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |                 int T; scanf("%d", &T);
      |                        ~~~~~^~~~~~~~~~

ソースコード

diff #

/*
	# Algorithm

	Naive

	## Time Complexity

	O(NT)
*/

#include <stdio.h>

constexpr int MOD = 1'000'000'007;

int main() {
	int A, B, N; scanf("%d%d%d", &A, &B, &N);

	using i64 = long long;
	while(N--) {
		int T; scanf("%d", &T);

		i64 r = 1, g = 1, b = 0;
		for(int t = 1; t <= T; t++) {
			if(t % 2) {
				(b += r * A + g * B) %= MOD;
			} else {
				g = r;
				r = b;
				b = 0;
			}
		}

		printf("%d\n", (r + g + b) % MOD);
	}
	return 0;
}
0