結果

問題 No.557 点対称
ユーザー nu50218nu50218
提出日時 2019-09-10 21:22:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 650 bytes
コンパイル時間 1,445 ms
コンパイル使用メモリ 166,660 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-02 16:21:36
合計ジャッジ時間 2,596 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const int MOD = 1000000007;

/*
(1,1)
(8,8)
(0,0)
(6,9)
(9,6)
*/

long long pow(long long x, long long n, long long mod) {
    long long ans = 1;
    while (n) {
        if (n % 2) ans *= x;
        x *= x;
        x %= mod;
        ans %= mod;
        n >>= 1;
    }
    return ans;
}

long long solve(long long N) {
    long long d = N / 2LL;
    if (d == 0) {
        return 1;
    }
    return 4LL * pow(5, d - 1, MOD) % MOD;
}

int main() {
    long long N;
    cin >> N;
    if (N % 2 == 1) {
        cout << solve(N - 1) * 3LL % MOD << endl;
    } else {
        cout << solve(N) << endl;
    }
}
0