# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
61996 |
2018-07-27T08:22:52 Z |
노영훈(#1796) |
popa (BOI18_popa) |
C++11 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#include "popa.h"
using namespace std;
static const int MX=1010, inf=2e9;
static int n;
static int S[MX];
static bool valid(int a, int b){
return 0<=a && a<n && a<=b && 0<=b && b<n;
}
static int gcd(int a, int b){
if(b==0) return a;
return gcd(b, a%b);
}
int query(int a, int b, int c, int d){
if(!valid(a,b) || !valid(c,d)) return 0;
int x=0, y=0;
for(int i=a; i<=b; i++) x=gcd(x,S[i]);
for(int i=c; i<=d; i++) y=gcd(y,S[i]);
return x==y;
}
static bool check(int L[], int R[]){
for(int i=0; i<n; i++) if(L[i]>=0 && S[L[i]]%S[i]!=0) return false;
for(int i=0; i<n; i++) if(L[i]>=0 && S[R[i]]%S[i]!=0) return false;
return true;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>n;
for(int i=0; i<n; i++) cin>>S[i];
int L[MX]={}, R[MX]={};
int root=solve(n, L, R);
cout<<(check(L, R) ? "OK" : "NO")<<'\n';
return 0;
}
Compilation message
popa.cpp: In function 'int main()':
popa.cpp:37:14: error: 'solve' was not declared in this scope
int root=solve(n, L, R);
^~~~~
popa.cpp:37:9: warning: unused variable 'root' [-Wunused-variable]
int root=solve(n, L, R);
^~~~