Submission #43418022
Source Code Expand
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xx first
#define yy second
#define ff(i,s,f) for(int i=s;i<f;i++)
#define fb(i,s,f) for(int i=(s)-1;i>=f;i--)
#define ffi(i,s,f) for(int i=s;i<=f;i++)
#define fbi(i,s,f) for(int i=s;i>=f;i--)
#define srt(a) sort(a.begin(),a.end());
#define srtg(a,int) sort(a.begin(),a.end(),greater<int>())
#define lb(a,x) lower_bound(a.begin(),a.end(),x)
#define ub(a,x) upper_bound(a.begin(),a.end(),x)
#define fnd(a,x) find(a.begin(),a.end(),x)
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef string str;
void solve(){
ll n,k;
cin>>n>>k;
int klk=0;
if(k>n){
cout<<"No\n";
return;
}
while(n>0){
klk+=n%3;
n/=3;
}
if(klk>k){
cout<<"No\n";
return;
}
if((klk&1)==(k&1)){
cout<<"Yes\n";
}else cout<<"No\n";
}
int main(){
ios;
int t=1;
cin>>t;
while(t--) solve();
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Ternary Decomposition |
User |
FEDIKUS |
Language |
C++ (GCC 9.2.1) |
Score |
300 |
Code Size |
1200 Byte |
Status |
AC |
Exec Time |
47 ms |
Memory |
3644 KiB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample-01.txt |
All |
in-01.txt, in-02.txt, in-03.txt, in-04.txt, in-05.txt, in-06.txt, sample-01.txt |
Case Name |
Status |
Exec Time |
Memory |
in-01.txt |
AC |
22 ms |
3484 KiB |
in-02.txt |
AC |
47 ms |
3612 KiB |
in-03.txt |
AC |
36 ms |
3512 KiB |
in-04.txt |
AC |
39 ms |
3548 KiB |
in-05.txt |
AC |
32 ms |
3512 KiB |
in-06.txt |
AC |
26 ms |
3644 KiB |
sample-01.txt |
AC |
5 ms |
3512 KiB |