标签:
很简单,求一下所有数的2和3的幂是任意调整的,把2和3的因子除掉以后必须相等。
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e5+5; ll a[maxn]; int main() { //freopen("in.txt","r",stdin); int n; scanf("%d",&n); for(int i = 0; i < n; i++){ scanf("%I64d",a+i); while(a[i]%2 == 0) a[i]/=2; while(a[i]%3 == 0) a[i]/=3; } for(int i = 1; i < n; i++){ if(a[i]!=a[i-1]) { puts("NO"); return 0; } } puts("YES"); return 0; }
Codeforces Round #318 (Div. 2) C Bear and Poker
标签:
原文地址:http://www.cnblogs.com/jerryRey/p/4770260.html