結果
| 問題 | No.891 隣接3項間の漸化式 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-01 08:55:45 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 661 bytes |
| 記録 | |
| コンパイル時間 | 459 ms |
| コンパイル使用メモリ | 94,584 KB |
| 実行使用メモリ | 9,600 KB |
| 最終ジャッジ日時 | 2026-04-19 07:15:46 |
| 合計ジャッジ時間 | 5,296 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 TLE * 1 -- * 16 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/iostream:43,
from main.cpp:1:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]',
inlined from 'int main()' at main.cpp:36:2:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:212:25: warning: 'x' may be used uninitialized [-Wmaybe-uninitialized]
212 | { return _M_insert(__n); }
| ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:22:12: note: 'x' was declared here
22 | ll x;
| ^
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;
int main()
{
ll a, b, n;
cin >> a >> b >> n;
ll x;
if (n == 0)x = 0;
else if (n == 1)x == 1;
else
{
ll x_last = 1;
ll x_last2 = 0;
rep(i, n - 1)
{
x = (a * x_last + b * x_last2) % mod;
x_last2 = x_last;
x_last = x;
}
}
co(x);
return 0;
}