提出 #43420346


ソースコード 拡げる

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define input(x) for(auto &a:x)cin>>a
#define print(x) for(auto &a:x){cout<<a<<' ';}cout<<nline
#define ppcl(x) __builtin_popcountll(x)
#define ppc(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define ll long long int
#define pb push_back
#define nline "\n"
#define INF LLONG_MAX
#define NINF LLONG_MIN
#define pii pair<int,int> 
#define fr first
#define sc second 
using namespace std;
using namespace __gnu_pbds;
#define precision(x) fixed << setprecision(x)
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
const ll mod = 1e9 + 7;
const int N = 200001;


void ninjamayank(){
    ll n,k;
    cin >> n >> k;
    ll prev = 1;
    ll op = 0;
    ll tmp = n;
    while(n > 0){
        ll rem = n%3;
        op += rem;
        n /= 3;
    }
    if(k > tmp){
        cout << "No" << nline;
        return;
    }
    if(k < op){
        cout << "No" << nline;
        return;
    }
    k -= op;
    cout << (k%2 == 0 ? "Yes" : "No") << nline;
}
int main(){
    // #ifndef ONLINE_JUDGE
    //     //for getting input from input1.txt
    //     freopen("input1.txt", "r", stdin);
    //     //for getting output from output1.txt
    //     freopen("output1.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); // remove in problems with online query
    int testcase = 1;
    cin >> testcase;
    int gtc = 1;
    while(testcase--){
        //cout << "Case #" << gtc << ": ";
        ninjamayank();
        gtc++;
    }
}

提出情報

提出日時
問題 A - Ternary Decomposition
ユーザ ninjamayank
言語 C++ (GCC 9.2.1)
得点 300
コード長 1676 Byte
結果 AC
実行時間 46 ms
メモリ 3616 KiB

コンパイルエラー

./Main.cpp: In function ‘void ninjamayank()’:
./Main.cpp:28:8: warning: unused variable ‘prev’ [-Wunused-variable]
   28 |     ll prev = 1;
      |        ^~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 1
AC × 7
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
in-01.txt AC 33 ms 3524 KiB
in-02.txt AC 46 ms 3592 KiB
in-03.txt AC 38 ms 3536 KiB
in-04.txt AC 41 ms 3468 KiB
in-05.txt AC 35 ms 3596 KiB
in-06.txt AC 28 ms 3616 KiB
sample-01.txt AC 4 ms 3456 KiB