Submission #873324

# Submission time Handle Problem Language Result Execution time Memory
873324 2023-11-14T20:28:57 Z bobbilyking Calvinball championship (CEOI15_teams) C++17
10 / 100
271 ms 1044 KB
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include<bits/stdc++.h>
#include<math.h>
using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pl;

#define K first
#define V second
#define G(x) ll x; cin >> x;
#define GD(x) ld x; cin >> x;
#define GS(s) string s; cin >> s;
#define EX(x) { cout << x << '\n'; exit(0); }
#define A(a) (a).begin(), (a).end()
#define F(i, l, r) for (ll i = (l); i < r; ++i)

#define NN 10010
#define M 1000007 // 998244353


ll f[NN*2], fi[NN*2];
constexpr ll bpow(ll b, ll e) {
	ll r = 1; for (; e; e/=2) {
		if (e&1) r=r*b%M;
		b=b*b%M;
	} 
	return r;
}
constexpr ll inv(ll b) {
	return bpow(b, M-2);
}

ll ncr(ll n, ll k) {
    if (min(n, k) < 0) return 0;
    if (n < k) return 0;
    if (n == k || k == 0) return 1;
return f[n] * fi[n-k]%M * fi[k]%M;
}

ll dp[NN];

int main(){
//    freopen("a.in", "r", stdin);
//    freopen("a.out", "w", stdout);

    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(20);
    

	f[0] = 1;
	F(i, 1, 2*NN) f[i] = f[i-1]*i%M;
	F(i, 0, 2*NN) fi[i] = inv(f[i]);

    dp[0] = 1;
    F(i, 1, NN) {
        F(k, 1, i+1) dp[i] += dp[i-k] * ncr(i-1, k-1)%M;
        dp[i]%=M;
    }
    // F(i, 0, 10) {
    //     cout << i << ": " << dp[i] << endl;
    // }
    ll answer = 1;
    G(n) for (ll left = n; left >= 1; --left) {
        G(x)
        answer = (answer + (x-1) * dp[left])%M;
    }
    cout << answer << '\n';

    
}
# Verdict Execution time Memory Grader output
1 Correct 251 ms 824 KB Output is correct
2 Correct 252 ms 788 KB Output is correct
3 Correct 253 ms 1044 KB Output is correct
4 Correct 251 ms 824 KB Output is correct
5 Correct 251 ms 804 KB Output is correct
6 Correct 252 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 251 ms 784 KB Output is correct
2 Incorrect 253 ms 1036 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 253 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 252 ms 788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 251 ms 820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 252 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 255 ms 848 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 271 ms 808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 257 ms 848 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 254 ms 864 KB Output isn't correct
2 Halted 0 ms 0 KB -