답안 #125402

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125402 2019-07-05T08:29:33 Z Touubs CATS (NOI14_cats) C++17
12 / 25
598 ms 6248 KB
#include <bits/stdc++.h>
using namespace std;
#define dout if(false) cout
#define int unsigned long long

void testcase() {
    int X, L, N;
    cin >> X >> L >> N;
    int originalX = X;
    X--;

    int level = L/(2*N) + 1;
    dout << "level: " << level << endl;

    int counterPerIter = 2 << level;
    int flipPerIter = 2 * counterPerIter - 1;

    int iterations = X / counterPerIter;
    int flips = 0;

    X = X % counterPerIter;

    dout << "counterPerIter: " << counterPerIter << endl;
    dout << "flipPerIter: " << flipPerIter << endl;

    while (X > 0) {
        //cout << "X: " << X << ", flips: " << flips << " | ";
        if ((X & 1) == 1) flips = flips ^ 1;
        X = X >> 1;
    }

    dout << endl << "end. flips: " << flips << endl;
    int min = (L/(2*N) + 1) * (2*N);
    cout << ((min | ((flips) & 1))) << endl;
}

signed main() {
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        testcase();
    }
    
}

Compilation message

cats.cpp: In function 'void testcase()':
cats.cpp:9:9: warning: unused variable 'originalX' [-Wunused-variable]
     int originalX = X;
         ^~~~~~~~~
cats.cpp:18:9: warning: unused variable 'iterations' [-Wunused-variable]
     int iterations = X / counterPerIter;
         ^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 598 ms 6248 KB Output isn't correct
2 Halted 0 ms 0 KB -