#include <set> #include <queue> #include <cstdio> #include <vector> #include <cstring> #include <algorithm> using namespace std; typedef long long LL; #define mem(x,y) memset(x, y, sizeof(x)) #define lson l,m,rt << 1 #define rson m+1,r,rt << 1 | 1 int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);} int lcm(int a, int b){return a / gcd(a, b) * b;} int main() { int T; scanf("%d", &T); for(int cas = 1; cas <= T; cas++) { int n, k, flag = 0; scanf("%d%d", &n, &k); if(n % 2 == 0) { n--; flag = 1; } LL all = (1 << (k + 1)) - 1; LL res = (all - n) >> 1; printf("Case #%d:\n", cas); for(int i = 0; i < k; i++) { LL temp = 1 << i; if(i == (k - 1)) printf("%I64d +\n",flag ? temp + 1 : temp); else if(res & 1) printf("%I64d -\n", temp); else printf("%I64d +\n", temp); res >>= 1; } } return 0; }
时间: 2024-12-23 07:06:59