#include <cstdio>
#include <queue>
using namespace std;
unsigned long long getPower(int);
void bfs();
queue<unsigned long long> q1, q2;
int k;
unsigned long long minv;
int main() {
// freopen("input.txt", "r", stdin);
setbuf(stdout, NULL);
int tc;
scanf("%d", &tc);
for(int i=1; i<=tc; i++) {
q1=queue<unsigned long long>();
q2=queue<unsigned long long>();
unsigned long long maxv;
scanf("%d", &k);
minv=getPower(k);
// printf("%llu\n", minv);
if(k<=4) {
minv=maxv=(1<<k);
}
else {
maxv=getPower(k);
bfs();
}
printf("Case #%d\n%llu %llu\n", i, minv, maxv);
}
return 0;
}
void bfs() {
q1.push(1);
for(int i=0; i<k; i++) {
// int cnt=0;////////////
while(!q1.empty()) {
// cnt++;///////////////
unsigned long long here=q1.front(); q1.pop();
unsigned long long there;
there=here*2;
q2.push(there);
if(i==k-1 && minv>there) minv=there;
if((here-1)%3==0 && ((here-1)/3)%2 != 0 && (here-1)/3 > 1 ) {
there=(here-1)/3;
q2.push(there);
if(i==k-1 && minv>there) {
minv=there;
}
}
}
q1=q2;
q2=queue<unsigned long long>();
// printf("cnt : %d\n", cnt);
}
}
unsigned long long getPower(int n) {
unsigned long long ret=1;
for(int i=0; i<n; i++) ret*=2;
//printf("ret : %llu\n", ret);
return ret;
}
댓글 없음:
댓글 쓰기