Submission #7584

#TimeUsernameProblemLanguageResultExecution timeMemory
7584dohyun0324경비원 (GA8_guard)C++98
8 / 100
60 ms1096 KiB
#include<stdio.h> int cnt,n,a[2510],m,ch[30],w; int gcd(int x,int y) { if(x%y==0) return y; return gcd(y,x%y); } void dfs(int x) { int i; if(x==n) { if(w>=2) { cnt++; } return; } dfs(x+1); for(i=1;i<=w;i++) { if(gcd(ch[i],a[x+1])!=1) break; } if(i!=w+1) return; ch[++w]=a[x+1]; dfs(x+1); ch[w--]=0; } int main() { int i,j,s; //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d",&a[i]); if(m<a[i]) m=a[i]; } //subtask 1 if(n<=20) { dfs(1); ch[++w]=a[1]; dfs(1); printf("%d",cnt); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...