結果
| 問題 |
No.831 都市めぐり
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-05-24 21:36:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 587 bytes |
| コンパイル時間 | 1,495 ms |
| コンパイル使用メモリ | 167,492 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-17 10:28:48 |
| 合計ジャッジ時間 | 1,977 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M
using namespace std;
int main()
{
int n;
while (~scanf("%d", &n)) {
__int128 ans = 0;
if (n==1) {
puts("0");
continue;
} else {
__int128 nn = n;
if (n % 2) {
ans = (nn*nn*nn + 3*nn*nn + 5*nn - 3)/6;
} else {
ans = (nn*nn*nn + 3*nn*nn + 5*nn - 6)/6;
}
}
printf("%lld\n", (long long)ans);
}
return 0;
}