📄 toj_2931.cpp
字号:
#include<cstdio>#include<cmath>#define MINNUM 1e-10#define MAXLEN 1010struct Fact{ int aFact[ 100 ]; int nOfFact;}; int note[ MAXLEN ] , nOfNote;double x;Fact xFact;void findFact( int n ){ int static i; xFact.nOfFact = 0; for( i = 3; i * i <= n; i++ ) { if( n % i == 0 ){ xFact.aFact[ xFact.nOfFact++ ] = i; while ( n % i == 0 ){ n /= i; } } }}int gcd( int a , int b ){ int static temp; while ( b != 0 ){ temp = b; b = a % b; a = temp; }// printf( "a = %d\n" , a ); return a;} int main(){ freopen( "c.in" , "r" , stdin ); freopen( "toj_2931_out.txt" , "w" , stdout ); int i , j ,nOfCase , xDenominator , xNumerator , fact5 , gcdForAll; scanf( "%d" , &nOfCase ); for( ; nOfCase > 0 ; nOfCase-- ){ scanf( "%lf" , &x ); scanf( "%d" , &nOfNote ); for( i = 0; i < nOfNote; i++ ) scanf( "%d" , ¬e[ i ] ); xDenominator = int (x * 100 + MINNUM);// printf( "xd = %d\n" , xDenominator ); fact5 = 0; while ( xDenominator % 5 == 0 && fact5 < 2 ){ xDenominator /= 5; fact5++; } if( fact5 != 2 ) printf( "no\n" ); else{ while ( xDenominator % 2 == 0 ){ // printf( "x = %d\n" , xDenominator ); xDenominator /= 2; }// findFact( xDenominator ); gcdForAll = 1; for( i = 0; i < nOfNote; i++ ){ gcdForAll = gcd ( gcdForAll , note[ i ] ); } while ( gcdForAll % 2 == 0 ) gcdForAll /= 2; if ( xDenominator % gcdForAll == 0 ) printf( "yes\n" ); else printf( "no\n" ); } } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -