标签:des style blog http io color ar os for
这道题目我们可以知道x2无论如何都是分母,而其他数字都可以通过括号转化为分子,所以我们一直除就好了,知道x2为1就好辣!
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 int gcd(int a,int b){return b==0?a:gcd(b,a%b);} 5 int T,t,n,a[100001]; 6 int main(){ 7 scanf("%d",&T); 8 while(T--){ 9 scanf("%d%d%d",&n,&a[1],&t); 10 for(int i=1;i<=n-2;i++) 11 scanf("%d",&a[i+1]); 12 for(int i=1;i<n;i++){ 13 t/=gcd(t,a[i]); 14 if(t==1){printf("YES\n");break;} 15 } 16 if(t!=1)printf("NO\n"); 17 } 18 return 0; 19 }
BZOJ 1385: [Baltic2000]Division expression
标签:des style blog http io color ar os for
原文地址:http://www.cnblogs.com/WNJXYK/p/4070259.html