結果
問題 | No.2519 Coins in Array |
ユーザー | gucci0512 |
提出日時 | 2023-10-27 22:46:34 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,212 bytes |
コンパイル時間 | 3,878 ms |
コンパイル使用メモリ | 231,304 KB |
実行使用メモリ | 8,048 KB |
最終ジャッジ日時 | 2023-10-27 22:46:47 |
合計ジャッジ時間 | 11,067 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 4 ms
5,276 KB |
testcase_02 | AC | 4 ms
5,276 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 4 ms
5,276 KB |
testcase_15 | AC | 4 ms
5,276 KB |
testcase_16 | WA | - |
testcase_17 | AC | 4 ms
5,276 KB |
testcase_18 | AC | 4 ms
5,276 KB |
testcase_19 | AC | 4 ms
5,276 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 286 ms
8,048 KB |
testcase_24 | AC | 267 ms
8,048 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 277 ms
8,048 KB |
testcase_28 | AC | 264 ms
8,048 KB |
testcase_29 | AC | 280 ms
8,048 KB |
testcase_30 | AC | 259 ms
7,784 KB |
testcase_31 | AC | 44 ms
5,408 KB |
testcase_32 | AC | 134 ms
6,464 KB |
testcase_33 | AC | 200 ms
6,992 KB |
testcase_34 | AC | 90 ms
5,936 KB |
testcase_35 | AC | 170 ms
6,992 KB |
testcase_36 | AC | 96 ms
5,672 KB |
testcase_37 | AC | 34 ms
5,280 KB |
testcase_38 | AC | 144 ms
6,464 KB |
testcase_39 | AC | 82 ms
5,936 KB |
testcase_40 | AC | 258 ms
8,048 KB |
ソースコード
#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; } } }