結果

問題 No.1275 綺麗な式
ユーザー longrunlongrun
提出日時 2020-10-30 23:47:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,095 bytes
コンパイル時間 2,017 ms
コンパイル使用メモリ 198,244 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-29 08:55:20
合計ジャッジ時間 4,365 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 1 ms
4,380 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 WA -
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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: メンバ関数 ‘matrix& matrix::operator*=(matrix)’ 内:
main.cpp:68:5: 警告: 非 void を戻す関数内に return 文がありません [-Wreturn-type]
   67 |         a = na; b = nb; c = nc; d = nd;
  +++ |+    return *this;
   68 |     }
      |     ^

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
#define debug(x) cout << x << endl;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;
// using mint = modint1000000007;

struct mint
{
    ll x;
    mint(ll x = 0) : x(x % MOD) {}
    mint& operator+=(const mint rh) { if((x += rh.x) >= MOD) x -= MOD; return *this; }
    mint& operator-=(const mint rh) { if((x += MOD-rh.x) >= MOD) x -= MOD; return *this; }
    mint& operator*=(const mint rh) { (x *= rh.x) %= MOD; return *this; }
    mint operator+(const mint rh) const { return mint(*this) += rh; }
    mint operator-(const mint rh) const { return mint(*this) -= rh; }
    mint operator*(const mint rh) const { return mint(*this) *= rh; }
    mint pow(ll k) const
    {
        if(!k) return 1;
        mint a = x;
        mint res = 1;
        while(k)
        {
            if(k & 1) res *= a;
            k >>= 1;
            a *= a;
        }
        return res;
    }
    mint inv() const { return pow(MOD-2); }
    mint& operator/=(const mint rh) { return *this *= rh.inv(); }
    mint operator/(const mint rh) { return mint(*this) /= rh; }
};

//2*2正方行列
struct matrix
{
    mint a, b, c, d;
    matrix(mint a, mint b, mint c, mint d) : a(a), b(b), c(c), d(d) {}
    matrix& operator*=(const matrix rh)
    {
        mint p = rh.a, q = rh.b, r = rh.c, s = rh.d;
        mint na, nb, nc, nd;
        na = a*p + b*r;
        nb = a*q + b*s;
        nc = c*p + d*r;
        nd = c*q + d*s;
        a = na; b = nb; c = nc; d = nd;
    }
    matrix operator*(const matrix rh) const { return matrix(*this) *= rh; }
};

matrix power(matrix x, ll k)
{
    if(k == 1)
    {
        return x;
    }
    matrix res = x;
    k--;
    while(k)
    {
        if(k & 1) res = (res * x);
        k >>= 1;
        x = (x * x);
    }
    return res;
}



int main()
{
    ll a, b, n;
    cin >> a >> b >> n;
    mint a1(2), a2(2*a);
    matrix p = power(matrix(mint(2*a), mint(mint(b)-mint(a*a)), mint(1), mint(0)), n);
    mint ans = p.c * a2 + p.d * a1;
    cout << ans.x << endl;
    return 0;
}
0