题解:P15889 [COCI 2025/2026 #6] 零花钱 / Džeparac
a_small_OIer · · 题解
题目传送门
思路
设母亲留下的金额为
将
因此,对于每个可能的
同时注意到
code
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
//十年OI一场空,不开long long见祖宗
LL n;
const int P = 1000000007;
LL p(LL a , LL b){//注意到 pow 是保留字(除了我应该没有人会忘吧qwq)
LL res = 1;
while(b){
if(b & 1)
res = res * a % P;
a = a * a % P;
b >>= 1;
}
return res;
}
int main(){
scanf("%lld" , &n);
printf("%lld" , p(2 , n / 2));
return 0;
}