#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define mem(dp,x) memset(dp,x,sizeof(dp))
#define pii pair<int,int>
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define ll long long
#define pb push_back
#define mid (l+r)/2
#define S second
#define F first
using namespace std;
const int inf = 1e9+9;
const int mod = 1e9+7;
ll n;
ll a[109];
ll F[109];
ll dp[19][100009];
ll bt(ll id,ll sum){
if(sum < 0) return 0;
if(id == 16) return (sum == 0);
ll &ret = dp[id][sum];
if(ret != -1) return ret;
ret = bt(id+1,sum)+bt(id+1,sum-F[id]);
return ret;
}
int main(){
fast,cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
F[1] = 1; F[2] = 2;
for(int i=3;i<=15;i++){
F[i] = (F[i-1]+F[i-2])%mod;
}
ll sum = 0; mem(dp,-1);
for(int i=0;i<n;i++){
sum += F[a[i]];
cout<<bt(1,sum)<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15180 KB |
Output is correct |
2 |
Incorrect |
7 ms |
15180 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15180 KB |
Output is correct |
2 |
Incorrect |
7 ms |
15180 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
22 ms |
30524 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15180 KB |
Output is correct |
2 |
Incorrect |
7 ms |
15180 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4027 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15180 KB |
Output is correct |
2 |
Incorrect |
7 ms |
15180 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |