結果
| 問題 | 
                            No.1810 RGB Biscuits
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-11-06 20:27:03 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 557 bytes | 
| コンパイル時間 | 201 ms | 
| コンパイル使用メモリ | 31,104 KB | 
| 最終ジャッジ日時 | 2025-01-25 14:18:49 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge8 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 TLE * 1 | 
| other | AC * 4 WA * 3 TLE * 13 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:37:26: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘i64’ {aka ‘long long int’} [-Wformat=]
   37 |                 printf("%d\n", (r + g + b) % MOD);
      |                         ~^     ~~~~~~~~~~~~~~~~~
      |                          |                 |
      |                          int               i64 {aka long long int}
      |                         %lld
main.cpp:20:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |         int A, B, N; scanf("%d%d%d", &A, &B, &N);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:24:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |                 int T; scanf("%d", &T);
      |                        ~~~~~^~~~~~~~~~
            
            ソースコード
/*
	# Algorithm
	Naive
	## Time Complexity
	O(NT) + Optimization
*/
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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;
}