Codeforces Bear and Poker

//#include<bits/stdc++.h>

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cmath>
#include<map>

using namespace std;

#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf

typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;

int main()
{
    fast;
    int n , i;
    LL x;
    vll v;
    while(cin >> n)
    {
        v.clear();

        for(i=0; i<n; i++)
        {
            cin >> x;

            while(x % 2 == 0)
            {
                x /= 2;
            }

            while(x % 3 == 0)
            {
                x /= 3;
            }

            v.push_back(x);
        }

        //for(i=0; i<n; i++) cout << v[i] << " ";

        bool f=true;

        for(i=0; i<n-1; i++)
        {
            if(v[i] != v[i+1])
            {
                f=false;
                break;
            }
        }

        puts(f==true ? "Yes" : "No");
    }

    return 0;
}

Comments

Popular posts from this blog

SPOJ-CMG - Collecting Mango

LightOJ 1009 - Back to Underworld

LeetCode Palindrome Number