Skip to content

Commit 0d48c78

Browse files
committed
Added 1829D - Gold Rush.cpp
1 parent e04b937 commit 0d48c78

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

1829D - Gold Rush.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// ॐ नमः शिवाय
2+
#include<bits/stdc++.h>
3+
using namespace std;
4+
#define ll long long
5+
6+
// Code Written By: Vikash Patel
7+
// Codeforces Profile: https://codeforces.com/profile/vikashpatel
8+
9+
bool split(int n, int m)
10+
{
11+
if(n == m)
12+
return true;
13+
if (n % 3 != 0 || n < m)
14+
return false;
15+
return split(n/3, m) || split((n / 3) * 2, m);
16+
}
17+
18+
int main()
19+
{
20+
int t;
21+
cin>>t;
22+
while(t--)
23+
{
24+
int n,m;
25+
cin>>n>>m;
26+
if(split(n,m))
27+
cout<<"YES"<<endl;
28+
else
29+
cout<<"NO"<<endl;
30+
}
31+
return 0;
32+
}

0 commit comments

Comments
 (0)