10416 | 2024-04-01 22:59:49 | 111 | Kiváló számok 2 | cpp17 | Accepted 100/100 | 3ms | 3540 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
int pow_mod(int x,int p){
int r=1;
while(p){
if(p%2){
r*=x;
r%=MOD;
}
x*=x;
x%=MOD;
p/=2;
}
return r;
}
int inv_mod(int x){
return pow_mod(x,MOD-2);
}
int geo_mod(int q,int n){
return (pow_mod(q,n)-1)*inv_mod(q-1)%MOD;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin>>T;
while(T--){
int N;
cin>>N;
int ans=0;
if(N%2==0){
ans=geo_mod(4,N/2);
ans++;
}
else{
ans=(geo_mod(4,N/2+1)-1)*inv_mod(2)%MOD;
}
cout<<ans<<'\n';
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1896 KiB | ||||
subtask2 | 13/13 | ||||||
2 | Accepted | 3ms | 2232 KiB | ||||
3 | Accepted | 3ms | 2360 KiB | ||||
subtask3 | 24/24 | ||||||
4 | Accepted | 3ms | 2524 KiB | ||||
5 | Accepted | 3ms | 2620 KiB | ||||
6 | Accepted | 2ms | 2832 KiB | ||||
7 | Accepted | 3ms | 3064 KiB | ||||
subtask4 | 34/34 | ||||||
8 | Accepted | 3ms | 3196 KiB | ||||
9 | Accepted | 3ms | 3288 KiB | ||||
10 | Accepted | 2ms | 3352 KiB | ||||
11 | Accepted | 2ms | 3332 KiB | ||||
subtask5 | 29/29 | ||||||
12 | Accepted | 2ms | 3336 KiB | ||||
13 | Accepted | 2ms | 3336 KiB | ||||
14 | Accepted | 2ms | 3332 KiB | ||||
15 | Accepted | 2ms | 3328 KiB | ||||
16 | Accepted | 2ms | 3336 KiB | ||||
17 | Accepted | 3ms | 3456 KiB | ||||
18 | Accepted | 2ms | 3540 KiB |