結果
問題 | No.831 都市めぐり |
ユーザー |
![]() |
提出日時 | 2019-05-24 21:51:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 642 bytes |
コンパイル時間 | 2,142 ms |
コンパイル使用メモリ | 192,728 KB |
最終ジャッジ日時 | 2025-01-07 03:58:25 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include<bits/stdc++.h>using namespace std;using Int = long long;template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}//INSERT ABOVE HEREsigned main(){Int n;cin>>n;if(n==1){cout<<0<<endl;return 0;}if(n==2){cout<<4<<endl;return 0;}Int ans=n;Int l=1,r=n;while(l<r){if(l+1==r){ans+=l*r;break;}if(l+2==r){Int m=l+1;ans+=l*m;ans+=r*m;break;}ans+=l*(r-1);ans+=r*(l+1);l++;r--;}cout<<ans<<endl;return 0;}