Submission #1482327
Source Code Expand
#pragma region include #include <iostream> #include <iomanip> #include <stdio.h> #include <sstream> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <cstring> #include <vector> #include <tuple> #include <bitset> #include <queue> #include <complex> #include <set> #include <map> #include <stack> #include <list> #include <fstream> #include <random> //#include <time.h> #include <ctime> #pragma endregion //#include ///////// #define REP(i, x, n) for(int i = x; i < n; ++i) #define rep(i,n) REP(i,0,n) #define ALL(X) X.begin(), X.end() ///////// #pragma region typedef typedef long long LL; typedef long double LD; typedef unsigned long long ULL; typedef std::pair<LL,LL> PLL;// typedef std::pair<int,int> PII;// #pragma endregion //typedef ////定数 const int INF = (int)1e9; const LL MOD = (LL)1e9+7; const LL LINF = (LL)1e18+20; const double PI = acos(-1.0); const double EPS = 1e-9; ///////// using namespace::std; LL f(int N,int D){ if( N == 1 ){ return D; } LL odd,even; if( N & 1 ){ odd = N; even = N-1; }else{ odd = N-1; even = N; } LL mask = 64; LL ans = 0; while(mask){ if( D & mask ){//奇数個作れる ans += odd * mask; }else{//偶数個作れる ans += even * mask; } mask >>= 1; } return ans; } void solve(){ int T; cin >> T; int N,D; while(T--){ cin >> N >> D; cout << f(N,D) << endl; } } #pragma region main signed main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;//小数を10進数表示 cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別 solve(); } #pragma endregion //main()
Submission Info
Submission Time | |
---|---|
Task | C - Cookie Breeding Machine |
User | akarin55 |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 1747 Byte |
Status | AC |
Exec Time | 3 ms |
Memory | 256 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
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 | 3 ms | 256 KB |
random_01.txt | AC | 3 ms | 256 KB |
random_02.txt | AC | 3 ms | 256 KB |
random_03.txt | AC | 3 ms | 256 KB |
random_04.txt | AC | 3 ms | 256 KB |