結果
問題 | No.831 都市めぐり |
ユーザー | veqcc |
提出日時 | 2019-05-24 21:43:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 927 bytes |
コンパイル時間 | 993 ms |
コンパイル使用メモリ | 101,252 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-17 10:31:33 |
合計ジャッジ時間 | 1,368 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <string> #include <vector> #include <random> #include <bitset> #include <queue> #include <cmath> #include <stack> #include <set> #include <map> typedef long long ll; using namespace std; const ll MOD = 1000000007LL; int main() { cin.sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n; cin >> n; if (n == 1) { cout << 0 << "\n"; return 0; } ll ans = 0; if (n % 2 == 0) { ll m = n; for (int i = 0; i < n / 2; i++) { ans += m * (2 * i + 2); m--; } ans += n; ans -= (n / 2) + 1; } else { ll m = n; for (int i = 0; i < n / 2; i++) { ans += m * (2 * i + 2); m--; } ans += n; ans += (n / 2) * (n / 2 + 1); } cout << ans << "\n"; return 0; }