結果
| 問題 | 
                            No.831 都市めぐり
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-05-23 06:56:57 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 692 bytes | 
| コンパイル時間 | 2,622 ms | 
| コンパイル使用メモリ | 193,200 KB | 
| 最終ジャッジ日時 | 2025-01-10 15:16:26 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 18 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         int n; scanf("%d",&n);
      |                ~~~~~^~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
int main(){
	int n; scanf("%d",&n);
// experiment
/*
	vector<lint> p(n);
	iota(p.begin(),p.end(),1);
	lint ans=1e7;
	vector<lint> pans;
	do{
		lint cost=0;
		rep(i,n) cost+=p[i]*p[(i+1)%n];
		if(ans>cost){
			ans=cost;
			pans=p;
		}
	}while(next_permutation(p.begin(),p.end()));
	cout<<ans<<endl;
	rep(i,n) cout<<pans[i]<<" "; cout<<endl;
*/
	vector<lint> p(n);
	int a=1,b=n,l=0,r=n-1;
	for(bool f=true;l<=r;f=!f){
		if(f) p[l]=a, p[r]=b;
		else  p[l]=b, p[r]=a;
		a++;
		b--;
		l++;
		r--;
	}
	lint ans=0;
	rep(i,n) ans+=p[i]*p[(i+1)%n];
	printf("%lld\n",ans);
	return 0;
}