Submission #43425534
Source Code Expand
Copy
#include <bits/stdc++.h>using namespace std;#define int long longsigned main() {int t;cin >> t;while (t--) {int n, k;cin >> n >> k;if (n < k) {cout << "No\n";continue;}vector<int> cnt(40, 0);vector<int> p3(40);p3[0] = 1;for (int i = 1; i <= 39; i++) p3[i] = p3[i - 1] * 3;int cntt = 0;for (int i = 39; i >= 0; i--) {int sm = n / p3[i];
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int t; cin >> t; while (t--) { int n, k; cin >> n >> k; if (n < k) { cout << "No\n"; continue; } vector<int> cnt(40, 0); vector<int> p3(40); p3[0] = 1; for (int i = 1; i <= 39; i++) p3[i] = p3[i - 1] * 3; int cntt = 0; for (int i = 39; i >= 0; i--) { int sm = n / p3[i]; n -= p3[i] * sm; cnt[i] = sm; cntt += sm; } if (cntt > k) { cout << "No\n"; continue; } // cout << cntt % 2 << '\n'; // cout << k % 2 << '\n'; if ((abs(cntt - k) % 2 == 1)) { cout << "No\n"; continue; } cout << "Yes\n"; } }
Submission Info
Submission Time | |
---|---|
Task | A - Ternary Decomposition |
User | Sharky |
Language | C++ (GCC 9.2.1) |
Score | 300 |
Code Size | 896 Byte |
Status | AC |
Exec Time | 292 ms |
Memory | 3536 KB |
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 | 240 ms | 3436 KB |
in-02.txt | AC | 292 ms | 3292 KB |
in-03.txt | AC | 264 ms | 3468 KB |
in-04.txt | AC | 260 ms | 3380 KB |
in-05.txt | AC | 248 ms | 3356 KB |
in-06.txt | AC | 233 ms | 3460 KB |
sample-01.txt | AC | 5 ms | 3536 KB |