結果

問題 No.557 点対称
コンテスト
ユーザー vjudge1
提出日時 2026-02-20 10:18:48
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 783 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,877 ms
コンパイル使用メモリ 211,668 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-02-20 10:18:52
合計ジャッジ時間 3,160 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int mod = 1e9 + 7;
int n;
inline int ksm(int a, int b, int mod)
{
    b = b % (mod - 1);
    int res = 1;
    while (b)
    {
        if (b & 1ll)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1ll;
    }
    return res;
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // freopen("crotate.in", "r", stdin);
    // freopen("crotate.out", "w", stdout);
    cin >> n;
    if (n == 1)
    {
        cout << 2 << "\n";
        return 0;
    }
    if (n % 2 == 1)
    {
        n /= 2;
        cout << 12 * ksm(5, n - 1, mod) % mod << "\n";
    }
    else
    {
        n /= 2;
        cout << 4 * ksm(5, n - 1, mod) % mod << "\n";
    }
}
0