제출 #389529

#제출 시각아이디문제언어결과실행 시간메모리
389529wiwihoBinary Subsequences (info1cup17_binary)C++14
12.90 / 100
64 ms31784 KiB
#include <bits/stdc++.h>

#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define printv(a, b) { \
    for(auto pv : a) b << pv << " "; \
    b << "\n"; \
}

using namespace std;

typedef long long ll;

using pii = pair<int, int>;

const ll MOD = 1000000007;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int sz = 2002;
    vector<vector<ll>> dp(sz + 1, vector<ll>(sz + 1));
    dp[1][1] = 1;
    for(int sum = 2; sum <= sz; sum++){
        for(int i = 1; i < sum; i++){
            int j = sum - i;
            dp[i][i + j] += dp[i][j];
            dp[i][i + j] %= MOD;
            dp[i + j][j] += dp[i][j];
            dp[i + j][j] %= MOD;
        }
    }

    vector<ll> ans(sz + 1);
    for(int i = 1; i <= sz; i++){
        for(int j = 1; i + j <= sz; j++){
            ans[i + j - 2] += dp[i][j];
            ans[i + j - 2] %= MOD;
        }
    }

    int T;
    cin >> T;
    while(T--){
        int n;
        cin >> n;
        cout << ans[n] << "\n-1\n";
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...