Submission #43418578


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=800005;
inline ll read() {
	static ll x=0,c=getchar(),f=1;
	for(f=1; c<=47||c>=58; c=getchar()) f=f&&(c^45);
	for(x=0; c>=48&&c<=57; c=getchar()) x=(x<<3)+(x<<1)+(c&15);
	return f?x:-x;
}
int main() {
	int t=read();
	while(t--) {
		ll n=read(),k=read(),ans=0,m=n;
		while(n) ans+=n%3,n/=3;
		puts(ans>k||(ans^k)&1||k>m?"No":"Yes");
	} 
	return 0;
}

Submission Info

Submission Time
Task A - Ternary Decomposition
User mod998244353
Language C++ (GCC 9.2.1)
Score 300
Code Size 448 Byte
Status AC
Exec Time 33 ms
Memory 3508 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 1
AC × 7
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 13 ms 3452 KiB
in-02.txt AC 33 ms 3352 KiB
in-03.txt AC 28 ms 3504 KiB
in-04.txt AC 27 ms 3388 KiB
in-05.txt AC 22 ms 3364 KiB
in-06.txt AC 19 ms 3508 KiB
sample-01.txt AC 7 ms 3384 KiB