結果
問題 |
No.557 点対称
|
ユーザー |
![]() |
提出日時 | 2017-08-11 23:22:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 621 bytes |
コンパイル時間 | 1,416 ms |
コンパイル使用メモリ | 159,728 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-12 21:56:07 |
合計ジャッジ時間 | 2,348 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long int64; int64 pow_mod(int64 x, int64 n, int64 mod) { int64 ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= mod; (x *= x) %= mod; n >>= 1; } return ret; } const int mod = 1e9 + 7; int main() { int64 N; cin >> N; if(N == 1) { cout << 2 << endl; } else if(N == 2) { cout << 4 << endl; } else if(N == 3) { cout << 12 << endl; } else if(N % 2 == 0LL) { N /= 2; --N; cout << pow_mod(5, N, mod) * 4 % mod << endl; } else { N /= 2; --N; cout << pow_mod(5, N, mod) * 3 * 4 % mod << endl; } }