結果
| 問題 |
No.557 点対称
|
| ユーザー |
🍮かんプリン
|
| 提出日時 | 2019-08-24 19:37:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,670 bytes |
| コンパイル時間 | 1,573 ms |
| コンパイル使用メモリ | 166,580 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 13:12:41 |
| 合計ジャッジ時間 | 2,533 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = MOD - 1;
const ll LLINF = 4e18;
struct mint {
private:
ll x;
public:
mint(ll x = 0) :x(x%MOD) {}
mint& operator+=(const mint a) {
if ((x += a.x) >= MOD) x -= MOD;
return *this;
}
mint& operator-=(const mint a) {
if ((x += MOD - a.x) >= MOD) x -= MOD;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= MOD;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
friend ostream& operator<<(ostream& os, const mint& n) {
return os << n.x;
}
};
//pow
template<typename T, typename U>
T pow(T n, U k) {
T x = 1;
while (k > 0) {
if (k & 1) {
x *= n;
}
n *= n;
k >>= 1;
}
return x;
}
int main() {
ll n; cin >> n;
mint ans = 1;
if (n == 1) {
ans = 2;
}
else {
if (n % 2 == 1) {
ans *= 3;
n--;
}
if (n > 0) ans *= 4;
ans *= pow(mint(5), (n - 2) / 2);
}
cout << ans << endl;
getchar(); getchar();
}
🍮かんプリン