結果

問題 No.2519 Coins in Array
ユーザー cho435cho435
提出日時 2023-10-28 14:03:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 806 bytes
コンパイル時間 4,180 ms
コンパイル使用メモリ 263,772 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-28 14:03:29
合計ジャッジ時間 8,876 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 91 ms
4,348 KB
testcase_24 AC 88 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 92 ms
4,348 KB
testcase_28 AC 91 ms
4,348 KB
testcase_29 AC 92 ms
4,348 KB
testcase_30 AC 80 ms
4,348 KB
testcase_31 AC 15 ms
4,348 KB
testcase_32 AC 44 ms
4,348 KB
testcase_33 AC 62 ms
4,348 KB
testcase_34 AC 30 ms
4,348 KB
testcase_35 AC 57 ms
4,348 KB
testcase_36 AC 24 ms
4,348 KB
testcase_37 AC 12 ms
4,348 KB
testcase_38 AC 47 ms
4,348 KB
testcase_39 AC 28 ms
4,348 KB
testcase_40 AC 59 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

ll f(ll a,ll b){
	if(gcd(a,b)==1) return (a-1)*(b-1);
	return 0;
}

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n) cin>>a.at(i);
	if(n>3){
		cout<<0<<endl;
		cout<<"1 2\n";
		cout<<"1 2\n";
		cout<<n-2<<" "<<n-3<<"\n";
		rep(i,n-4){
			cout<<"1 "<<n-3-i<<"\n";
		}
	}else{
		if(n==2){
			cout<<f(a.at(0),a.at(1))<<"\n";
			cout<<"1 2\n";
		}else{
			vector<int> v={a.at(0),a.at(1),a.at(2)};
			ll mn=1e18;
			int j=-1;
			rep(i,3){
				ll tmp=f(f(v.at(0),v.at(1)),v.at(2));
				if(mn>tmp){
					mn=tmp;
					j=i;
				}
				v.push_back(v.front());
				v.erase(v.begin());
			}
			cout<<mn<<"\n";
			cout<<j+1<<" "<<(j+1)%3+1<<"\n";
			cout<<"1 2\n";
		}
	}
}
0