結果
| 問題 | No.1500 Super Knight |
| コンテスト | |
| ユーザー |
seven_three
|
| 提出日時 | 2021-05-07 21:54:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,153 bytes |
| コンパイル時間 | 753 ms |
| コンパイル使用メモリ | 92,492 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 09:46:18 |
| 合計ジャッジ時間 | 1,775 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 33 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
string s[61];
int b1[12] = { 3,3,2,0,-2,-3,-3,-3,-2,0,2,3 };
int b2[12] = { 0,2,3,3,3,2,0,-2,-3,-3,-3,-2 };
int ans1[4] = { 1,12,65 };
long long mod = 1000000007;
int main() {
long long n;
cin >> n;
if (n < 3) {
cout << ans1[n] << endl;
}
else {
if (n % 2 == 1) {
long long ans = 0;
long long a = (10 + (n - 3) * 3) % mod;
ans += a * (a - 1) % mod;
ans += a * (a - 1) % mod;
ans %= mod;
long long b = ((((n + 1) / 2) * ((n + 1) / 2)) + (n / 2) * (n / 2)) / 2 % mod;
ans -= b * 4, ans %= mod;
cout << (ans + mod) % mod << endl;
}
else {
long long ans = 0;
long long a = 10 + (n - 3) * 3;
ans += a * a % mod;
ans += (a - 1) * (a - 1) % mod;
ans %= mod;
ans -= (n / 2) * (n / 2) % mod * 4 % mod, ans %= mod;
cout << (ans + mod) % mod << endl;
}
}
}
seven_three