Submission #11432160
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) ((lli)(x).size())
using lli = long long;
using lld = long double;
using ulli = unsigned long long int;
using pll = pair<lli, lli>;
using ttt = pair<lli, pll>;
using vttt = vector<ttt>;
using vll = vector<pll>;
using vl = vector<lli>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using cd = complex<lld>;
const double PI = acos(-1);
#ifndef tejasp
#define trace(...) {}
#define cotra(...) {}
#define end_routine() {}
#define localsys 0
#define endl '\n'
#endif
inline lli mpow(lli a, lli b, lli m=mod) {
a = a%mod; b = b%(mod-1);
if(a<0) a+=mod; if(b<0) b+=mod-1;
if(a==0) return 0;
lli ans = 1;
while (b) {
if (b&1) ans=(ans*a)%m;
a=(a*a)%m; b/=2;
}
return ans;
}
#define MAXN 1010
lli fact[MAXN], invf[MAXN], po[MAXN][MAXN];
void __prec()
{
fact[0]=1;
fol(i,1,MAXN) fact[i]=(fact[i-1]*i)%mod;
fol(i,0,MAXN) invf[i]=mpow(fact[i],mod-2);
fol(i,0,MAXN) fol(j,0,MAXN) po[i][j]=mpow(invf[i],j);
}
lli get(int n, int a, int k, int p)
{
return (((((fact[n]*invf[a])%mod)*po[k][p])%mod)*invf[p])%mod;
}
std::vector<vl> dp(MAXN,vl(MAXN,0));
int tejas_919(int kkkk)
{
lli n, m, k, q, u, v, temp=0, ans=0;
lli a, b, c, d;
cin>>n>>a>>b>>c>>d;
trace(n,MAXN)
fol(i,a,b+1) //size of each block
{
dp[i-1][0]=1;
fol(k,0,n)
{
if(dp[i-1][k]==0) continue;
fol(j,c,d+1) //number of blocks
{
temp=k+(i*j);
if(temp>n) break;
dp[i][temp]+=(dp[i-1][k]*get(n-k,n-temp,i,j))%mod;
dp[i][temp]%=mod;
}
}
ans+=dp[i][n];
}
ans%=mod;
cotra(dp)
cout<<ans<<endl;
return 0;
}
signed main()
{
#ifdef tejasp
freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
#endif
if(!localsys) { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); }
cout << fixed << setprecision(10);
__prec();
int t=1;
//cin>>t;
fol(i,0,t) { tejas_919(i+1); }
end_routine();
if(localsys) system("pause");
}
Submission Info
Submission Time
2020-04-02 14:52:38+0900
Task
E - Grouping
User
white_horseman
Language
C++14 (GCC 5.4.1)
Score
0
Code Size
2748 Byte
Status
WA
Exec Time
80 ms
Memory
16256 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:111:33: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
if(localsys) system("pause");
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
0 / 600
Status
Set Name
Test Cases
Sample
sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All
sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_many_01.txt, subtask_1_many_02.txt, subtask_1_many_03.txt, subtask_1_many_04.txt, subtask_1_max_01.txt, subtask_1_max_02.txt, subtask_1_min_01.txt, subtask_1_randa_01.txt, subtask_1_randa_02.txt, subtask_1_randb_01.txt, subtask_1_randb_02.txt
Case Name
Status
Exec Time
Memory
sample_01.txt
AC
56 ms
16256 KB
sample_02.txt
AC
56 ms
16256 KB
sample_03.txt
WA
80 ms
16256 KB
sample_04.txt
AC
56 ms
16256 KB
subtask_1_many_01.txt
WA
78 ms
16256 KB
subtask_1_many_02.txt
WA
71 ms
16256 KB
subtask_1_many_03.txt
WA
76 ms
16256 KB
subtask_1_many_04.txt
WA
73 ms
16256 KB
subtask_1_max_01.txt
AC
57 ms
16256 KB
subtask_1_max_02.txt
AC
57 ms
16256 KB
subtask_1_min_01.txt
AC
56 ms
16256 KB
subtask_1_randa_01.txt
AC
56 ms
16256 KB
subtask_1_randa_02.txt
AC
57 ms
16256 KB
subtask_1_randb_01.txt
AC
57 ms
16256 KB
subtask_1_randb_02.txt
WA
56 ms
16256 KB