Submission #1819955


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

long long test, n, d, dem, ma[10], res;

void pt(long long x){
    dem = 0;
    long long tmp[10];
    for(long long i = 1; i <= 7; i++) tmp[i] = 0;
    while(x > 0){
        dem ++;
        tmp[dem] = x % 2;
        x = x / 2;
    }
    for(long long i = 1; i <= 7; i++) ma[i] = tmp[8 - i];
}

int main()
{
    cin >> test;
    while(test--){
        cin >> n >> d;
        pt(d);
        res = 0;
        for(long long i = 1; i <= 7; i++){
            if(n % 2 == 0){
                if(ma[i] == 0) res = res + n * pow(2, 7 - i);
                else res = res + (n - 1) * pow(2, 7 - i);
            }
            else{
                if(ma[i] == 0) res = res + (n - 1) * pow(2, 7 - i);
                else res = res + n * pow(2, 7 - i);
            }
        }
        cout << res << endl;
    }
}

Submission Info

Submission Time
Task C - Cookie Breeding Machine
User vjudge1
Language C++14 (GCC 5.4.1)
Score 100
Code Size 851 Byte
Status AC
Exec Time 4 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 6
Set Name Test Cases
All 00_sample.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt
Case Name Status Exec Time Memory
00_sample.txt AC 1 ms 256 KB
random_00.txt AC 4 ms 256 KB
random_01.txt AC 4 ms 256 KB
random_02.txt AC 4 ms 256 KB
random_03.txt AC 4 ms 256 KB
random_04.txt AC 4 ms 256 KB