結果

問題 No.8123 Calculated N !
コンテスト
ユーザー paranormal22
提出日時 2025-10-31 20:57:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 468 bytes
コンパイル時間 1,733 ms
コンパイル使用メモリ 194,492 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-31 20:57:12
合計ジャッジ時間 3,027 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4 WA * 2
other AC * 1 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

typedef long long ll;
const ll mod = 1e9+7;

ll solve(ll n)
{
    ll ans = 1;
    ll base = 2;
    while(n > 0)
    {
        if(n % 2 == 1) ans = (ans * base) % mod;
        base = (base * base) % mod;
        n /= 2;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin >> n;
    cout << solve(n - 1) << endl;
    return 0;
}
0