简单题,求一下所有数的2和3的幂是任意调整的,把2和3的因子除掉以后必须相等。
求lcm,爆了long long。我得好好反省一下,对连乘不敏感
#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; }