結果
| 問題 |
No.557 点対称
|
| ユーザー |
とばり
|
| 提出日時 | 2018-09-09 04:18:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 775 bytes |
| コンパイル時間 | 1,713 ms |
| コンパイル使用メモリ | 166,224 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 02:41:06 |
| 合計ジャッジ時間 | 2,774 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
using uint64 = unsigned long long;
const int64 MOD = 1e9 + 7;
int64 powMod(int64 a, int64 n)
{
int64 res = 1, p = a % MOD;
while (n > 0)
{
if (n & 1)
{
(res *= p) %= MOD;
}
(p *= p) %= MOD;
n >>= 1;
}
return res;
}
int main()
{
cin.tie(nullptr);
ios::sync_with_stdio(false);
int64 N;
cin >> N;
if (N == 1)
{
// 0, 1, 8
cout << 2 << endl;
return 0;
}
int64 ans = 1;
if (N & 1)
{
ans = 3;
N--;
}
// 1, 8, 0, 9, 6
(ans *= powMod(5, N / 2 - 1)) %= MOD;
// 1, 8, 9, 6
(ans *= 4) %= MOD;
cout << ans << endl;
return 0;
}
とばり