結果

問題 No.831 都市めぐり
ユーザー 👑 obakyan
提出日時 2019-05-25 16:43:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 724 bytes
コンパイル時間 504 ms
コンパイル使用メモリ 72,956 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-17 15:05:21
合計ジャッジ時間 1,104 ms
ジャッジサーバーID
(参考情報)
judge6 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <iomanip>
#include <numeric>
#define L64 long long
#define UL64 unsigned long long
#define MOD (1000000007LL)

UL64 get(UL64 idx, UL64 n)
{
  if(idx * 2 <= n){
    if(idx % 2 == 0){
      return n + 1UL - idx;
    } else {
      return idx;
    }
  } else {
    if((n - idx) % 2 == 0){
      return idx;
    } else {
      return n + 1UL - idx;
    }
  }
}

int main(void)
{
  UL64 n;
  std::cin >> n;
  UL64 sum = n;
  for(UL64 i = 1; i < n; i++){
    sum = sum + get(i, n) * get(i + 1, n);
  }
  std::cout << (n == 1 ? 0 : sum) << std::endl;
}
0