結果

問題 No.891 隣接3項間の漸化式
ユーザー totori_nyaatotori_nyaa
提出日時 2019-09-20 21:59:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 473 bytes
コンパイル時間 1,516 ms
コンパイル使用メモリ 165,208 KB
実行使用メモリ 7,624 KB
最終ジャッジ日時 2023-10-12 19:05:35
合計ジャッジ時間 6,756 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,592 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 54 ms
4,348 KB
testcase_04 AC 106 ms
4,348 KB
testcase_05 AC 111 ms
4,352 KB
testcase_06 AC 145 ms
4,348 KB
testcase_07 AC 102 ms
4,352 KB
testcase_08 AC 92 ms
4,348 KB
testcase_09 AC 122 ms
4,352 KB
testcase_10 AC 22 ms
4,352 KB
testcase_11 AC 59 ms
4,352 KB
testcase_12 AC 172 ms
4,352 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 109 ms
4,352 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 13 ms
4,352 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 17 ms
4,368 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    
    ll mod = 1e9+7;
    ll a,b,n;
    cin>>a>>b>>n;
    ll x[3];
    x[0]=0,x[1]=1,x[2]=a;
    for(int i=3;i<=n;i++){
        x[i%3] = (a*x[(i+2)%3])%mod + (b*x[(i+1)%3])%mod;
        x[i%3] %= mod;
        if(i==n){
            cout << x[i%3] << "\n";
            return 0;
        } 
    }



}
0