This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define eb emplace_back
#define iter(a) a.begin(), a.end()
#define lsort(a) sort(iter(a))
#define uni(a) a.resize(unique(iter(a)) - a.begin())
#define printv(a, b) {\
for(auto pv : a) b << pv << " ";\
b << "\n";\
}
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
ll inv(ll a){
ll b = MOD - 2;
ll ans = 1;
while(b > 0){
if(b & 1) ans = ans * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return ans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
assert(n <= 15);
vector<ll> fib(22);
fib[0] = 1;
fib[1] = 1;
for(int i = 2; i <= 21; i++){
fib[i] = fib[i - 1] + fib[i - 2];
}
ll sum = 0;
for(int i = 0; i < n; i++){
int x;
cin >> x;
assert(x <= 15);
sum += fib[x];
ll ans = 0;
for(int j = 0; j < (1 << 21); j++){
ll now = 0;
for(int k = 0; k < 21; k++){
if(1 << k & j) now += fib[k + 1];
}
if(now == sum) ans++;
}
cout << ans << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |