結果
| 問題 | 
                            No.831 都市めぐり
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-05-24 23:12:47 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 587 bytes | 
| コンパイル時間 | 1,560 ms | 
| コンパイル使用メモリ | 165,632 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-17 12:23:07 | 
| 合計ジャッジ時間 | 2,399 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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;
}