結果

問題 No.831 都市めぐり
ユーザー Shuz*Shuz*
提出日時 2018-08-29 20:42:53
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 925 bytes
コンパイル時間 1,276 ms
コンパイル使用メモリ 154,428 KB
最終ジャッジ日時 2024-04-27 02:36:24
合計ジャッジ時間 1,692 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:10:27: error: ‘lcm’ function uses ‘auto’ type specifier without trailing return type
   10 | #define def        inline auto
      |                           ^~~~
main.cpp:16:1: note: in expansion of macro ‘def’
   16 | def  lcm(ll a,ll b) {return a*b/gcd(a,b);}
      | ^~~
main.cpp:10:27: note: deduced return type only available with ‘-std=c++14’ or ‘-std=gnu++14’
   10 | #define def        inline auto
      |                           ^~~~
main.cpp:16:1: note: in expansion of macro ‘def’
   16 | def  lcm(ll a,ll b) {return a*b/gcd(a,b);}
      | ^~~
main.cpp:10:27: error: ‘dig’ function uses ‘auto’ type specifier without trailing return type
   10 | #define def        inline auto
      |                           ^~~~
main.cpp:17:1: note: in expansion of macro ‘def’
   17 | def  dig(ll a)      {return to_string(a).length();}
      | ^~~
main.cpp:10:27: note: deduced return type only available with ‘-std=c++14’ or ‘-std=gnu++14’
   10 | #define def        inline auto
      |                           ^~~~
main.cpp:17:1: note: in expansion of macro ‘def’
   17 | def  dig(ll a)      {return to_string(a).length();}
      | ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll     = long long;
using prefix = __attribute__((constructor))void;

const ll MOD = 1000000007;
const ll INF = 9223372036854775807LL;

#define elif       else if
#define def        inline auto
#define func       inline ll
#define lp(i,a,n)  for(ll i=(a),i##_1=(n);i<i##_1;++i)
#define rep(i,n)   lp(i,0,n)

func gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
def  lcm(ll a,ll b) {return a*b/gcd(a,b);}
def  dig(ll a)      {return to_string(a).length();}
prefix init()      {cin.tie(0),ios::sync_with_stdio(0);}

signed main(){
  
  ll n,s=0;
  cin>>n;
  if(n==1){
    cout<<"0\n";
    return 0;
  }
  if(n&1){
    ll N=(n-1)/2;
    cout<<(n*(n-1)*N/2-N*(2*N+1)*(2*N-1)/3+n*(n+3)*N/2-N*(4*N*N+6*N-1)/3+n)<<"\n";
  }
  else{
    rep(i,n-1){
      if(i&1){
        s+=(n-i)*(i+2);
      }
      else{
        s+=(i+1)*(n-(i+1));
      }
    }
    s+=n/2;
    cout<<s+n<<"\n";
  }
}
0