这题解得太机智。 他是把一个棍子 连成一个圆。
然后 剪切。 每次切中点。 一边 则能保证围成一个多边形。
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
using namespace std;
#define ll long long
typedef unsigned long long ull;
#define maxn 100000+100
#define INF 1<<30
ll gcd(ll a, ll b){
return b ? gcd(b,a%b) : a;
}
ll pow_(ll a, ll b){
if(b == 0)
return 1;
ll x = pow_(a, b/2);
ll ans = x*x;
if(b % 2 == 1)
ans = ans * a;
return ans;
}
int main (){
ll up[60];
ll down[60];
for(ll i = 1; i <= 50; i++){
ll z = pow_(2,i);
ll a = z - (i+1);
ll b = z;
if(a != 0){
ll x = gcd(a,b);
a /= x;
b /= x;
}
if(a == 0)
b = 1;
up[i] = a;
down[i] = b;
}
ll num;
ll counts = 0;
scanf("%lld",&num);
while(num--){
ll n,k;
scanf("%lld%lld",&n,&k);
printf("Case #%lld: %lld/%lld\n",++counts,up[k],down[k]);
}
return 0;
}