http://www.cnblogs.com/fraud/ ——by fraud
这场的前两题完全是手速题。。。A题写了7分钟,交的时候已经500+了,好在B题出的速度勉强凑活吧,and C题也没有FST
Limak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are n players (including Limak himself) and right now all of them have bids on the table. i-th of them has bid with size ai dollars.
Each player can double his bid any number of times and triple his bid any number of times. The casino has a great jackpot for making all bids equal. Is it possible that Limak and his friends will win a jackpot?
First line of input contains an integer n (2 ≤ n ≤ 105), the number of players.
The second line contains n integer numbers a1, a2, ..., an (1 ≤ ai ≤ 109) — the bids of players.
Print "Yes" (without the quotes) if players can make their bids become equal, or "No" otherwise.
4
75 150 75 50
Yes
3
100 150 250
No
In the first sample test first and third players should double their bids twice, second player should double his bid once and fourth player should both double and triple his bid.
It can be shown that in the second sample test there is no way to make all bids equal.
A题没啥好说的,把因为可以乘2或乘三,那只要看看除了2和3之外,其他的因子是否相同即可
1 //##################### 2 //Author:fraud 3 //Blog: http://www.cnblogs.com/fraud/ 4 //##################### 5 //#pragma comment(linker, "/STACK:102400000,102400000") 6 #include <iostream> 7 #include <sstream> 8 #include <ios> 9 #include <iomanip> 10 #include <functional> 11 #include <algorithm> 12 #include <vector> 13 #include <string> 14 #include <list> 15 #include <queue> 16 #include <deque> 17 #include <stack> 18 #include <set> 19 #include <map> 20 #include <cstdio> 21 #include <cstdlib> 22 #include <cmath> 23 #include <cstring> 24 #include <climits> 25 #include <cctype> 26 using namespace std; 27 #define XINF INT_MAX 28 #define INF 0x3FFFFFFF 29 #define mp(X,Y) make_pair(X,Y) 30 #define pb(X) push_back(X) 31 #define rep(X,N) for(int X=0;X<N;X++) 32 #define rep2(X,L,R) for(int X=L;X<=R;X++) 33 #define dep(X,R,L) for(int X=R;X>=L;X--) 34 #define clr(A,X) memset(A,X,sizeof(A)) 35 #define IT iterator 36 typedef long long ll; 37 typedef pair<int,int> PII; 38 typedef vector<PII> VII; 39 typedef vector<int> VI; 40 int a[100010]; 41 int main() 42 { 43 ios::sync_with_stdio(false); 44 int n; 45 cin>>n; 46 rep(i,n){ 47 cin>>a[i]; 48 while(a[i]%2==0)a[i]/=2; 49 while(a[i]%3==0)a[i]/=3; 50 } 51 int ff = 0; 52 rep(i,n-1)if(a[i]!=a[i+1])ff = 1; 53 if(ff)cout<<"No"<<endl; 54 else cout<<"Yes"<<endl; 55 return 0; 56 }