#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 353;
const lo mod = 1000000007;
int n,m,b[li],a[li],k,t,comb[li][li],dp[li][li][4];
int cev;
string s;
vector<int> v;
inline int add(int x,int y){
if(x+y>=mod)return x+y-mod;
return x+y;
}
inline int mul(int x,int y){
return (x%mod)*(y%mod)%mod;
}
inline int f(int sira,int how,int flag){
int cevv=0;
if(how<0)return 0;
if(how==0)return flag;
if(sira>n){
return 0;
}
if(~dp[sira][how][flag])return dp[sira][how][flag];
for(int i=0;i<=how;i++){
cevv=add(cevv,mul(comb[how][i],f(sira+1,how-i,flag|(sira==i?1:0))));
}
return dp[sira][how][flag]=cevv;
}
int main(void){
memset(dp,-1,sizeof(dp));
scanf("%d",&n);
comb[0][0]=1;
FOR{
for(int j=0;j<=n;j++){
comb[i][j]=comb[i-1][j];
if(j)comb[i][j]=add(comb[i][j],comb[i-1][j-1]);
}
}
printf("%d\n",f(1,n,0));
return 0;
}
Compilation message
zapina.cpp: In function 'int main()':
zapina.cpp:59:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
~~~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2304 KB |
Output is correct |
2 |
Correct |
2 ms |
2304 KB |
Output is correct |
3 |
Correct |
2 ms |
2304 KB |
Output is correct |
4 |
Correct |
1 ms |
2304 KB |
Output is correct |
5 |
Correct |
2 ms |
2304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2304 KB |
Output is correct |
2 |
Correct |
2 ms |
2304 KB |
Output is correct |
3 |
Correct |
2 ms |
2304 KB |
Output is correct |
4 |
Correct |
1 ms |
2304 KB |
Output is correct |
5 |
Correct |
2 ms |
2304 KB |
Output is correct |
6 |
Correct |
1 ms |
2304 KB |
Output is correct |
7 |
Correct |
2 ms |
2304 KB |
Output is correct |
8 |
Correct |
2 ms |
2304 KB |
Output is correct |
9 |
Correct |
2 ms |
2304 KB |
Output is correct |
10 |
Correct |
2 ms |
2304 KB |
Output is correct |
11 |
Correct |
2 ms |
2304 KB |
Output is correct |
12 |
Correct |
2 ms |
2304 KB |
Output is correct |
13 |
Correct |
2 ms |
2304 KB |
Output is correct |
14 |
Correct |
3 ms |
2304 KB |
Output is correct |
15 |
Correct |
2 ms |
2304 KB |
Output is correct |
16 |
Correct |
3 ms |
2304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2304 KB |
Output is correct |
2 |
Correct |
2 ms |
2304 KB |
Output is correct |
3 |
Correct |
2 ms |
2304 KB |
Output is correct |
4 |
Correct |
1 ms |
2304 KB |
Output is correct |
5 |
Correct |
2 ms |
2304 KB |
Output is correct |
6 |
Correct |
1 ms |
2304 KB |
Output is correct |
7 |
Correct |
2 ms |
2304 KB |
Output is correct |
8 |
Correct |
2 ms |
2304 KB |
Output is correct |
9 |
Correct |
2 ms |
2304 KB |
Output is correct |
10 |
Correct |
2 ms |
2304 KB |
Output is correct |
11 |
Correct |
2 ms |
2304 KB |
Output is correct |
12 |
Correct |
2 ms |
2304 KB |
Output is correct |
13 |
Correct |
2 ms |
2304 KB |
Output is correct |
14 |
Correct |
3 ms |
2304 KB |
Output is correct |
15 |
Correct |
2 ms |
2304 KB |
Output is correct |
16 |
Correct |
3 ms |
2304 KB |
Output is correct |
17 |
Correct |
193 ms |
2716 KB |
Output is correct |
18 |
Correct |
3 ms |
2304 KB |
Output is correct |
19 |
Correct |
43 ms |
2560 KB |
Output is correct |
20 |
Correct |
2 ms |
2304 KB |
Output is correct |
21 |
Correct |
257 ms |
2764 KB |
Output is correct |
22 |
Correct |
30 ms |
2432 KB |
Output is correct |
23 |
Correct |
4 ms |
2304 KB |
Output is correct |
24 |
Correct |
55 ms |
2560 KB |
Output is correct |
25 |
Correct |
37 ms |
2552 KB |
Output is correct |
26 |
Correct |
79 ms |
2560 KB |
Output is correct |
27 |
Correct |
358 ms |
2816 KB |
Output is correct |
28 |
Correct |
364 ms |
2936 KB |
Output is correct |
29 |
Correct |
365 ms |
2816 KB |
Output is correct |
30 |
Correct |
382 ms |
2816 KB |
Output is correct |
31 |
Correct |
376 ms |
2936 KB |
Output is correct |
32 |
Correct |
375 ms |
2816 KB |
Output is correct |
33 |
Correct |
377 ms |
2816 KB |
Output is correct |
34 |
Correct |
384 ms |
2936 KB |
Output is correct |
35 |
Correct |
387 ms |
2816 KB |
Output is correct |
36 |
Correct |
408 ms |
2828 KB |
Output is correct |
37 |
Correct |
413 ms |
2828 KB |
Output is correct |