感觉里面有好多技巧。。
#include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #define PII pair<int, int> #define SZ(x) ((int)x.size()) #define ull unsigned long long using namespace std; const int N = 1e6 + 7; const int inf = 0x3f3f3f3f; const LL INF = 0x3f3f3f3f3f3f3f3f; const int mod = 1e6 + 3; const double eps = 1e-8; LL n, k; LL power(LL a, LL b) { b %= mod - 1; LL ans = 1; while(b) { if(b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; } return ans; } int main() { scanf("%lld%lld", &n, &k); if(n < 63 && (1ll << n) < k) { puts("1 1"); } else { LL num = 0; for(LL i = k - 1; i; i /= 2) num += i / 2; LL A = power(2, n), B = 1; for(LL i = 1; i < k; i++) { B = B * (A - i) % mod; if(A == i) break; } LL inv = power(power(2, num), mod - 2); B = B * inv % mod; A = power(A, k - 1) * inv % mod; printf("%lld %lld\n", (A - B + mod) % mod, A); } return 0; } /* */