104142024-04-01 22:49:27111Kiváló számok 2cpp17Runtime error 71/100101ms7616 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;
		}
		cout<<v[N]<<'\n';
	}
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1836 KiB
subtask213/13
2Accepted3ms2032 KiB
3Accepted3ms2248 KiB
subtask324/24
4Accepted3ms2468 KiB
5Accepted3ms2560 KiB
6Accepted3ms2684 KiB
7Accepted3ms2904 KiB
subtask434/34
8Accepted87ms7124 KiB
9Accepted98ms7348 KiB
10Accepted82ms6464 KiB
11Accepted101ms7616 KiB
subtask50/29
12Runtime error4ms3808 KiB
13Runtime error4ms3808 KiB
14Runtime error4ms3932 KiB
15Runtime error4ms3904 KiB
16Runtime error4ms3908 KiB
17Runtime error4ms3908 KiB
18Runtime error4ms4052 KiB