結果

問題 No.891 隣接3項間の漸化式
ユーザー tactac
提出日時 2019-09-20 22:01:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,419 bytes
コンパイル時間 1,420 ms
コンパイル使用メモリ 164,144 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-12 19:08:01
合計ジャッジ時間 8,190 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 51 ms
4,352 KB
testcase_04 AC 100 ms
4,348 KB
testcase_05 AC 104 ms
4,352 KB
testcase_06 AC 136 ms
4,352 KB
testcase_07 AC 95 ms
4,352 KB
testcase_08 AC 87 ms
4,352 KB
testcase_09 AC 115 ms
4,348 KB
testcase_10 AC 21 ms
4,348 KB
testcase_11 AC 56 ms
4,348 KB
testcase_12 AC 162 ms
4,348 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 1 ms
4,352 KB
testcase_16 AC 103 ms
4,352 KB
testcase_17 WA -
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 12 ms
4,352 KB
testcase_20 WA -
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 16 ms
4,348 KB
testcase_23 WA -
testcase_24 AC 1 ms
4,348 KB
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;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T modpow(T a, int b) { return b ? (pow(a * a, b / 2) * (b % 2 ? a : 1)) % inf : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    int a, b, n;
    cin >> a >> b >> n;
    
    /*
    double al, be;
    al = (a + sqrt(a * a + 4 * b)) / 2;
    be = (a - sqrt(a * a + 4 * b)) / 2;
    cout << al << " " << be << endl;
    // cout << al + be << endl;
    
    double c = pow(be, n) / (1 - al);
    double ali = pow(al, n - 1);
    double xi = c + ali * (1 - c);
    cout << xi << endl;
     */
    
    int x = 0, y = 1;
    rep(i, n - 1) {
        int z = ((ll)a * y % inf + (ll)b * x % inf) % inf;
        x = y;
        y = z;
    }
    cout << y << endl;
}
0