Submission #43417908


Source Code Expand

/** @file
 * @ingroup


 */
#include <bits/stdc++.h>
using namespace std;
template <typename T> inline void O(const T &x) { cout << x << '\n'; }
template <typename T, typename... W> inline void O(const T &x, const W &...b) {
  cout << x << ' ';
  O(b...);
}
template <typename T> inline void rd(T &x) { cin >> x; }
template <typename T, typename... W> inline void rd(T &x, W &...b) {
  cin >> x;
  rd(b...);
}
#ifndef MISAKA
#define err(...)
#else
#define err(...) fprintf(stderr, __VA_ARGS__)
#endif
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef long double dbl;
typedef pair<int, int> pii;
typedef uniform_int_distribution<int> r32;
typedef uniform_int_distribution<i64> r64;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define shuf(L, R) shuffle((L), (R), rng)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define FOR(i, j, k) for (int i = (j); i <= (k); ++i)
#define ROF(i, j, k) for (int i = (k); i >= (j); --i)
template <typename T> inline void ckmin(T &a, const T &b) { a = min(a, b); }
template <typename T> inline void ckmax(T &a, const T &b) { a = max(a, b); }
//#define IOFILE "a"
#define MULTI
const int N = 0;

inline void sol() {
  i64 n, k;
  rd(n, k);
  int u = 0;
  while (n) u += n % 3, n /= 3;
  O((k>=u && !((k-u)&1)) ? "Yes": "No");
}

int main() {
#ifndef MISAKA
#ifdef IOFILE
  freopen(IOFILE ".in", "r", stdin);
  freopen(IOFILE ".out", "w", stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
#endif
#ifdef MULTI
  int T;
  cin >> T;
  while (T--)
#endif
    sol();
  return 0;
}

Submission Info

Submission Time
Task A - Ternary Decomposition
User misaka18931
Language C++ (GCC 9.2.1)
Score 300
Code Size 1682 Byte
Status AC
Exec Time 45 ms
Memory 3480 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 30 ms 3424 KiB
in-02.txt AC 45 ms 3400 KiB
in-03.txt AC 38 ms 3460 KiB
in-04.txt AC 38 ms 3424 KiB
in-05.txt AC 35 ms 3480 KiB
in-06.txt AC 29 ms 3320 KiB
sample-01.txt AC 5 ms 3388 KiB