結果
| 問題 |
No.2519 Coins in Array
|
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2023-10-27 21:33:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,099 bytes |
| コンパイル時間 | 2,042 ms |
| コンパイル使用メモリ | 197,128 KB |
| 最終ジャッジ日時 | 2025-02-17 14:38:40 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 32 WA * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++){
cin >> A[i];
}
auto f = [&](long long x, long long y){
if (gcd(x, y) > 1){
return (long long) 0;
} else {
return (x - 1) * (y - 1);
}
};
if (N >= 4){
cout << 0 << endl;
cout << 1 << ' ' << 2 << endl;
cout << 3 << ' ' << 4 << endl;
cout << N - 3 << ' ' << N - 2 << endl;
for (int i = N - 3; i >= 2; i--){
cout << i << ' ' << i - 1 << endl;
}
} else if (N == 2){
cout << f(A[0], A[1]) << endl;
cout << 1 << ' ' << 2 << endl;
} else {
long long a = f(f(A[0], A[1]), A[2]);
long long b = f(f(A[1], A[2]), A[0]);
long long c = f(f(A[2], A[0]), A[1]);
cout << min({a, b, c}) << endl;
if (a <= b && b <= c){
cout << 1 << ' ' << 2 << endl;
cout << 1 << ' ' << 2 << endl;
} else if (b <= c){
cout << 2 << ' ' << 3 << endl;
cout << 1 << ' ' << 2 << endl;
} else {
cout << 1 << ' ' << 3 << endl;
cout << 1 << ' ' << 2 << endl;
}
}
}
SSRS