题解:P11909 [NHSPC 2023] H. 整数的回文分解法
five_rice_water · · 题解
可以说这题主要考察的是比赛经验。
因为这道题的数据范围
于是就发现了以下规律,第一列的数字枚举的是
1 1
2 2
3 2
4 4
5 4
6 8
7 8
8 16
9 16
10 32
或许到这里你已经发现了规律了,对于一个数字
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 105;
const int Mod = 1e9 + 7;
int t, n;
int QuickPower(int x, int k) {
int ans = 1;
int base = x;
while (k) {
if (k & 1)
ans *= base, ans %= Mod;
k >>= 1;
base *= base, base %= Mod;
}
return ans;
}
signed main() {
cin >> t;
while (t--) {
cin >> n;
cout << QuickPower(2, n / 2) << endl;
}
return 0;
}
希望会证明的大佬早日给出证明。