結果

問題 No.2519 Coins in Array
ユーザー gucci0512
提出日時 2023-10-27 22:46:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,212 bytes
コンパイル時間 3,700 ms
コンパイル使用メモリ 230,772 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2024-09-25 14:47:47
合計ジャッジ時間 12,073 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 21 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
#include <atcoder/all>
// url
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=b-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x);
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
typedef long long ll;
typedef long double lld;
using namespace std;
using namespace atcoder;
const int eratosSize=201010;
int eratos[eratosSize];
void Init(){
rep(i,0,eratosSize)eratos[i]=-1;
eratos[0]=1;
eratos[1]=1;
rep(i,2,eratosSize){
if(eratos[i]!=-1)continue;
eratos[i]=i;
int x=i*2;
while(x<eratosSize){
if(eratos[x]==-1){
eratos[x]=i;
}
x+=i;
}
}
}
int idx[eratosSize];
typedef pair<ll,int> P;
int main(void){
ios::sync_with_stdio(false);
cin.tie(nullptr);
// int x,y;cin >> x >> y;
// rep(z,1,x*y+1){
// int a=0;
// cout << z << " ";
// while(a*x<=z){
// int b=z-a*x;
// if(b%y==0){
// cout << a << " " << b/y << endl;
// break;
// }
// a++;
// }
// if(a*x>z){
// cout << -1 << " " << -1 << endl;
// }
// }
Init();
fill(idx,idx+eratosSize,-1);
int N;cin >> N;
vector<P> A(N);
int a=-1,b=-1;
rep(i,0,N){
cin >> A[i].first;
A[i].second=i;
if(a!=-1)continue;
int tmp=A[i].first;
while(tmp>1){
int p=eratos[tmp];
if(idx[p]==-1){
idx[p]=i;
}
else if(idx[p]!=i){
a=idx[p];
b=i;
break;
}
while(tmp%p==0){
tmp/=p;
}
}
}
if(a!=-1){
cout << 0 << endl;
cout << a+1 << " " << b+1 << endl;
rrep(i,1,N-1){
cout << 1 << " " << i+1 << endl;
}
}
else{
cout << 1 << endl;
rep(i,1,N){
cout << 1 << " " << i+1 << endl;
}
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0