結果

問題 No.535 自然数の収納方法
ユーザー btkbtk
提出日時 2017-04-16 23:07:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,302 bytes
コンパイル時間 1,535 ms
コンパイル使用メモリ 166,100 KB
実行使用メモリ 7,500 KB
最終ジャッジ日時 2023-09-26 09:06:21
合計ジャッジ時間 7,280 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
}
/*
  想定TLE解法
  始点を0にしてA_iをN通り決めうちするO(N^3)
 */
const int mod=1e9+7;
int N;
inline LL count(int s){
    vector<int> dp(N,0);
    dp[s]=1;
    REP(i,N-1){
        vector<int> nxt(N,0);
        REP(j,N-1){
            dp[j+1]+=dp[j];
            if(dp[j+1]>=mod)dp[j+1]-=mod;
        }
        REP(j,N){
            nxt[j]=dp[min(N-1,j+i)];
        }
        swap(dp,nxt);
    }
    LL res=0;
    REP(i,s+1)res+=dp[i];
    return res%mod;
}
int main(){
    cin>>N;
    LL res=0;
    REP(i,N)res+=count(i);
    cout<<res%mod<<endl;
    return 0;
}
0