結果

問題 No.1275 綺麗な式
ユーザー koi_kotyakoi_kotya
提出日時 2020-10-30 23:08:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,449 bytes
コンパイル時間 1,823 ms
コンパイル使用メモリ 171,760 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-29 08:09:39
合計ジャッジ時間 3,928 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 WA -
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 2 ms
4,376 KB
testcase_41 WA -
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 1 ms
4,380 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';
ll const mod = 1e9+7;

vector<vector<ll>> prod(vector<vector<ll>>& a, vector<vector<ll>>& b, ll mod) {
    vector<vector<ll>> ret(a.size(),vector<ll>(b[0].size(),0));
    for (int i = 0;i < a.size();++i) for (int j = 0;j < b[0].size();++j) for (int k = 0;k < a[0].size();++k) {
        ret[i][j] += a[i][k]*b[k][j];
        ret[i][j] %= mod;
    }
    return ret;
}

int main() {
    ll a,b,n;
    cin >> a >> b >> n;
    vector<vector<ll>> ans(2,vector<ll>(1,0)),c(2,vector<ll>(2));
    ans[0][0] = 2*a;
    ans[1][0] = 2;
    c[0][0] = 2*a;
    c[0][1] = -a*a+b;
    c[1][0] = 1;
    c[1][1] = 0;
    if (n == 0) {
        cout << 2 << newl;
        return 0;
    }
    n--;
    while (n) {
        if (n&1) ans = prod(c,ans,mod);
        c = prod(c,c,mod);
        n /= 2;
    }
    cout << (ans[0][0]+mod)%mod << newl;
}
0