Skip to content

Instantly share code, notes, and snippets.

@hikariyo
Created December 15, 2025 04:54
Show Gist options
  • Select an option

  • Save hikariyo/ada5be7f2e2b294f6ad651ac7793fa3d to your computer and use it in GitHub Desktop.

Select an option

Save hikariyo/ada5be7f2e2b294f6ad651ac7793fa3d to your computer and use it in GitHub Desktop.
// #include <bits/stdc++.h>
#include <iostream>
using namespace std;
const int P = 10007;
int qpow(int a, int k) {
int res = 1;
while (k) {
if (k & 1) res = res * a % P;
a = a * a % P;
k >>= 1;
}
return res;
}
int solve() {
int n;
cin >> n;
return (qpow(2, n+1) + qpow(4, n)) % P * qpow(4, P-2) % P;
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int T;
cin >> T;
while (T--) cout << solve() << '\n';
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment