結果

問題 No.1491 銀将
ユーザー Manuel1024
提出日時 2021-04-30 22:26:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 479 bytes
コンパイル時間 469 ms
コンパイル使用メモリ 63,360 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 01:57:58
合計ジャッジ時間 1,186 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
using ll = long long int;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    ans += (((n-1)/2)*4+3) * ((n+1)/2);
    ans += ((n/2)*4+1) * ((n+2)/2);
    ans += n*2+1;
    //cerr << ans << endl;
    //cerr << (n-(1-n%2))*2+1 << " " << ((n/2)*2)*2+1 << " " << n*2+1 << endl;
    ans += ((n-(1-n%2))*2+1)*((n-1)/2);//((n/2)*2+n%2)*2+1
    ans += (((n/2)*2)*2+1)*((n-2)/2);
    if(n == 1) ans--;
    cout << ans << endl;
    return 0;
}
0