結果

問題 No.535 自然数の収納方法
ユーザー btkbtk
提出日時 2017-04-16 22:54:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,284 bytes
コンパイル時間 1,603 ms
コンパイル使用メモリ 168,752 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 09:06:09
合計ジャッジ時間 3,531 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 10 ms
4,376 KB
testcase_08 AC 32 ms
4,380 KB
testcase_09 AC 40 ms
4,376 KB
testcase_10 AC 48 ms
4,376 KB
testcase_11 AC 7 ms
4,376 KB
testcase_12 AC 20 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 15 ms
4,376 KB
testcase_15 AC 50 ms
4,376 KB
testcase_16 AC 32 ms
4,376 KB
testcase_17 AC 52 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 54 ms
4,380 KB
testcase_20 AC 54 ms
4,380 KB
testcase_21 AC 54 ms
4,376 KB
testcase_22 AC 54 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

const int mod=1e9+7;
vector<LL> count(LL N,vector<LL> ini){
    auto dp=ini;
    REP(i,N-1){
        REP(j,N-1)(dp[j+1]+=dp[j])%=mod;
        vector<LL> nxt(N,0);
        LL sa=max(i-1,0);
        REP(j,N){
            (nxt[j]+=dp[min(N-1,j+sa)])%=mod;
        }
        swap(dp,nxt);
    }
    return dp;
}
int main(){
    int N;
    cin>>N;
    vector<LL> S(N,0);
    S[0]=1;
    auto A = count(N,S);
    fill(ALL(S),1);
    auto B=count(N,S);
    LL res=0;
    for(auto &it:B)(res+=it)%=mod;
    (res+=mod-A.back())%=mod;
    cout<<res<<endl;
    return 0;
}
0