結果

問題 No.831 都市めぐり
ユーザー Yumeno UkihashiYumeno Ukihashi
提出日時 2019-05-24 21:35:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 565 bytes
コンパイル時間 1,643 ms
コンパイル使用メモリ 166,436 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 12:19:37
合計ジャッジ時間 2,325 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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");
        } 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;
}
0