10415 | 2024-04-01 22:55:30 | 111 | Kiváló számok 2 | cpp17 | Runtime error 71/100 | 150ms | 7544 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;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin>>T;
while(T--){
int N;
cin>>N;
vector<int>v(N+1);
v[0]=1;
v[1]=0;
for(int i=2;i<=N;i++){
v[i]=(pow_mod(2,i-2)+v[i-2])%MOD;
}
int ans=0;
if(N%2==0){
for(int i=0;i<=N-2;i+=2){
ans+=pow_mod(2,i);
ans%=MOD;
}
ans++;
}
else{
for(int i=1;i<=N-2;i+=2){
ans+=pow_mod(2,i);
ans%=MOD;
}
}
cout<<ans<<'\n';
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1832 KiB | ||||
subtask2 | 13/13 | ||||||
2 | Accepted | 3ms | 2052 KiB | ||||
3 | Accepted | 3ms | 2268 KiB | ||||
subtask3 | 24/24 | ||||||
4 | Accepted | 4ms | 2504 KiB | ||||
5 | Accepted | 4ms | 2700 KiB | ||||
6 | Accepted | 4ms | 2884 KiB | ||||
7 | Accepted | 4ms | 2964 KiB | ||||
subtask4 | 34/34 | ||||||
8 | Accepted | 129ms | 7112 KiB | ||||
9 | Accepted | 145ms | 7220 KiB | ||||
10 | Accepted | 122ms | 6264 KiB | ||||
11 | Accepted | 150ms | 7544 KiB | ||||
subtask5 | 0/29 | ||||||
12 | Runtime error | 4ms | 3960 KiB | ||||
13 | Runtime error | 4ms | 4140 KiB | ||||
14 | Runtime error | 4ms | 4256 KiB | ||||
15 | Runtime error | 4ms | 4256 KiB | ||||
16 | Runtime error | 4ms | 4564 KiB | ||||
17 | Runtime error | 4ms | 4612 KiB | ||||
18 | Runtime error | 4ms | 4756 KiB |