Submission #341395

# Submission time Handle Problem Language Result Execution time Memory
341395 2020-12-29T15:50:41 Z A_D Zapina (COCI20_zapina) C++14
22 / 110
1000 ms 364 KB
/*
ID: antwand1
TASK: pprime
LANG: C++
*/
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define du long double
#define F first
#define S second
#define FOR(a,b) for(int a=1;a<=b;a++)
#define FORl(a,b) for(a=1;a<=b;a++)
#define FOR0(a,b) for(int a=1;a<b;a++)
#define FORl0(a,b) for(a=0;a<b;a++)
#define ii pair<int,int>
using namespace std;
const int MOD=1e9+7;
const int N=500;
int fact[N];
int a[N];
int n;
ll po(ll x,ll os)
{
    if( os == 0 )
        return 1;

    ll z = po(x,os/2);

    if( os&1 )
        return z*z%MOD*x%MOD;

    return z*z%MOD;
}
ll modInv(ll x) { return po(x,MOD-2); }
ll c(ll n,ll r) { return fact[n]*modInv(fact[r]*fact[n-r]%MOD)%MOD; }
ll g(ll n,ll r) { return fact[n]*modInv(fact[n-r]%MOD)%MOD; }
int bc(int j)
{
    if(j==n){
        //cout<<a[0];
        for(int i=0;i<n;i++)if(a[i]==i+1)return 1;
        return 0;
    }
    int ret=0;
    for(int i=0;i<n;i++){
        a[i]++;
        ret+=bc(j+1)%MOD;
        a[i]--;
    }
    return ret;
}
main()
{
    cin>>n;
    for(int i=0;i<n;i++)a[i]=0;
    cout<<bc(0);
}



Compilation message

zapina.cpp:53:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   53 | main()
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 11 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 11 ms 364 KB Output is correct
6 Execution timed out 1096 ms 364 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 11 ms 364 KB Output is correct
6 Execution timed out 1096 ms 364 KB Time limit exceeded
7 Halted 0 ms 0 KB -