solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
#include<bits/stdc++.h> using namespace std; const int N=105,mod=1e9+7; inline int add(int a,int b){return a+b>=mod?a+b-mod:a+b;} inline int mul(int a,int b){return 1ll*a*b%mod;} int n,m,l,r; int b[N],c[N],p[N]; int f[N*N],g[N*N]; map<int,int> ans; inline int solve(int x){ for(int i=0;i<=n*100;i++)g[i]=1; for(int i=1;i<=n;i++){ for(int j=0;j<max(i*x+p[i],0);j++)f[j]=0; for(int j=max(i*x+p[i],0);j<=n*100;j++){ if(j>c[i])f[j]=add(g[j],mod-g[j-c[i]-1]); else f[j]=g[j]; } g[0]=f[0]; for(int j=1;j<=n*100;j++)g[j]=add(g[j-1],f[j]); } return g[n*100]; } int main(){ cin>>n; for(int i=1;i<=n;i++)cin>>c[i]; for(int i=1;i<n;i++)cin>>b[i]; for(int i=1;i<=n;i++) for(int j=1;j<i;j++)p[i]+=(i-j)*b[j]; l=0,r=100000; for(int i=1;i<=n;i++)l=min(l,-((p[i]-1)/i+1)),r=min(r,(n*100-p[i]-1)/i+1); for(int i=l;i<=r;i++)ans[i]=solve(i); int q; cin>>q; int res=1; for(int i=1;i<=n;i++)res=mul(res,c[i]+1); while(q--){ int x; scanf("%d",&x); if(x<l)printf("%d\n",res); else if(x>r)puts("0"); else printf("%d\n",ans[x]); } return 0; }
9
CPP
#include <iostream> #include <algorithm> constexpr int N = 105; constexpr int p = 1000000007; int add(int x, int y) { return (x += y) >= p ? x - p : x; } int sub(int x, int y) { return (x -= y) < 0 ? x + p : x; } int n, q, k; int c[N], b[N]; int f[N][N * N]; int s[2][N * N]; int l[N]; int main() { std::ios::sync_with_stdio(false), std::cin.tie(nullptr); std::cin >> n; int sumc = 0; for (int i = 1; i <= n; ++i) std::cin >> c[i], sumc += c[i]; for (int i = 1; i < n; ++i) std::cin >> b[i]; std::cin >> q; while (q--) { std::cin >> k; int sumb = k; for (int i = 1; i <= n; ++i) { l[i] = l[i - 1] + sumb; sumb += b[i]; } f[0][0] = 1; for (int i = 0; i <= sumc; ++i) s[0][i] = 1; for (int i = 1; i <= n; ++i) { for (int j = 0; j < l[i] && j <= sumc; ++j) s[1][j] = 0; for (int j = std::max(l[i], 0); j <= sumc; ++j) { f[i][j] = add(f[i][j], sub(s[0][j], j - c[i] - 1 >= 0 ? s[0][j - c[i] - 1] : 0)); s[1][j] = add(f[i][j], j > 0 ? s[1][j - 1] : 0); } std::swap(s[0], s[1]); } int min = k * n + sumb - k; int ans = 0; for (int i = std::max(min, 0); i <= sumc; ++i) { ans = add(ans, f[n][i]); } std::cout << ans << '\n'; } return 0; }
9
CPP
#include<cmath> #include<cstdio> #include<vector> #include<algorithm> #include<map> using namespace std; int main() { int n, M=1000000007, tmp, maxc=100; vector<int> c; scanf("%d", &n); int sumc=0; for(int i=0;i<n;++i) { scanf("%d", &tmp); c.push_back(tmp); sumc+=tmp; } int sumb=0, global_bi_over_i_ub=0; vector<int> b(n, 0); for(int i=0;i<n-1;++i) { scanf("%d", &tmp); sumb = sumb+tmp; b[i+1] = b[i] + sumb; global_bi_over_i_ub = min(global_bi_over_i_ub, -(b[i+1] / (i+2))); } int global_x_ub = maxc+global_bi_over_i_ub; int q; vector<int> x; scanf("%d", &q); for(int i=0;i<q;++i) { scanf("%d", &tmp); x.push_back(max(global_x_ub-maxc-5, min(global_x_ub+5, tmp))); } //printf("ub: %d", global_x_ub); map<int,int> x2ans; for(int xval=global_x_ub+5;xval>=global_x_ub-maxc-5;--xval) { vector<int> *p_ans=nullptr, *p_ans_last=nullptr; p_ans_last = new vector<int>(sumc+2,0); (*p_ans_last)[0]=1; for(int i=0;i<n;++i) { p_ans = new vector<int>(sumc+2, 0); int sum_last = 0, lower_bound=xval*(i+1)+b[i]; //printf("lb=%d, xval=%d, mul=%d, b=%d\n", lower_bound, xval, xval*(i+1), b[i]); for(int j=0;j<=c[i];++j) { sum_last = (sum_last + (*p_ans_last)[j])%M; (*p_ans)[j] = sum_last; } for(int j=c[i]+1;j<=sumc;++j) { sum_last = (sum_last - (*p_ans_last)[j-c[i]-1] + M) % M; sum_last = (sum_last + (*p_ans_last)[j]) % M; (*p_ans)[j] = sum_last; } for(int j=0;j<lower_bound && j<=sumc+1;++j) (*p_ans)[j]=0; swap(p_ans, p_ans_last); delete p_ans; } int cnt=0; for(int i=0;i<=sumc;++i) cnt = (cnt + (*p_ans_last)[i])%M; x2ans[xval] = cnt; delete p_ans_last; } for(int i=0;i<q;++i) { printf("%d\n", x2ans[x[i]]); } return 0; }
9
CPP
#ifdef DEBUG #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; typedef long double ld; #ifdef DEBUG #define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr) #else #define eprintf(...) ; #endif #define sz(x) ((int) (x).size()) #define TASK "text" const int inf = (int) 1.01e9; const long long infll = (long long) 1.01e18; const ld eps = 1e-9; const ld pi = acos((ld) -1); #ifdef DEBUG mt19937 mrand(300); #else mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); #endif int rnd(int x) { return mrand() % x; } void precalc() { } const int mod = (int) 1e9 + 7; int mul(int a, int b) { return (long long) a * b % mod; } void add(int &a, int b) { a += b; if (a >= mod) { a -= mod; } } const int maxn = 105; int n; int c[maxn], b[maxn]; bool read() { if (scanf("%d", &n) < 1) { return false; } for (int i = 0; i < n; ++i) { scanf("%d", &c[i]); } for (int i = 0; i + 1 < n; ++i) { scanf("%d", &b[i]); } return true; } const int maxx = maxn * maxn; int dp[maxx], ndp[maxx]; void solve() { int q; scanf("%d", &q); for (int qq = 0; qq < q; ++qq) { int x; scanf("%d", &x); for (int i = 0; i < maxx; ++i) { dp[i] = 0; } dp[0] = 1; int s = 0; for (int i = 0; i < n; ++i) { s += x; int sum = 0; for (int j = 0, k = 0; j < maxx; ++j) { add(sum, dp[j]); while (j - k > c[i]) { add(sum, mod - dp[k]); ++k; } ndp[j] = (j < s ? 0 : sum); } swap(dp, ndp); if (i + 1 < n) { x += b[i]; } } int res = 0; for (int i = 0; i < maxx; ++i) { add(res, dp[i]); } printf("%d\n", res); } } int main() { precalc(); #ifdef DEBUG assert(freopen(TASK ".in", "r", stdin)); assert(freopen(TASK ".out", "w", stdout)); #endif while (read()) { solve(); #ifdef DEBUG eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC); #endif } return 0; }
9
CPP
/** * @brief codeforces * @author yao */ #include <cstdlib> #include <cstdio> #include <cctype> #include <cstring> #include <utility> #include <algorithm> #include <functional> #include <climits> #define ft first #define sd second #ifdef DBG # define dbg_pri(x...) fprintf(stderr,x) #else # define dbg_pri(x...) 0 # define NDEBUG #endif //DBG #include <cassert> typedef unsigned int uint; typedef long long int lli; typedef unsigned long long int ulli; #define N 128 #define P ((int)1e9+7) int c[N]; int b[N]; int s[N]; int dp[N*N]; int main() { int n; scanf("%d", &n); for(int i=0;i<n;++i) scanf("%d", &c[i]); for(int i=0;i<n-1;++i) scanf("%d", &b[i]); int q; scanf("%d", &q); for(int qc=0; qc<q; ++qc) { int x; scanf("%d", &x); s[0] = x; for(int i=1;i<n;++i) s[i] = s[i-1]+b[i-1]; memset(dp,0,sizeof(dp)); dp[0] = 1; int tar = 0; for(int i=0;i<n;++i) { for(int j=i*100,ej=std::max(0,tar);j>=ej;--j)if(dp[j]) { for(int k=j+1,ek=j+c[i];k<=ek;++k) dp[k] = (dp[k] + dp[j]) % P; } tar += s[i]; } int ans = 0; for(int i=std::max(0,tar),e=n*100;i<=e;++i) ans = (ans + dp[i]) %P; printf("%d\n", ans); } return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; //using namespace atcoder; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define FOR(i, begin, end) for(int i=(begin);i<(end);i++) #define REP(i, n) FOR(i,0,n) #define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--) #define IREP(i, n) IFOR(i,0,n) #define Sort(v) sort(v.begin(), v.end()) #define Reverse(v) reverse(v.begin(), v.end()) #define all(v) v.begin(),v.end() #define SZ(v) ((int)v.size()) #define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x)) #define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x)) #define chmax(a, b) a = max(a, b) #define chmin(a, b) a = min(a, b) #define bit(n) (1LL<<(n)) #define debug(x) cout << #x << "=" << x << endl; #define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; } #define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} } #define pb push_back #define fi first #define se second #define int long long #define INF 1000000000000000000 template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; } template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; } template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; } template<typename T> void Out(T x) { cout << x << endl; } template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); } using vec = vector<int>; using mat = vector<vec>; using Pii = pair<int, int>; using v_bool = vector<bool>; using v_Pii = vector<Pii>; //int dx[4] = {1,0,-1,0}; //int dy[4] = {0,1,0,-1}; //char d[4] = {'D','R','U','L'}; const int mod = 1000000007; //const int mod = 998244353; template<long long MOD> struct ModInt{ using ll = long long; ll val; void setval(ll v) { val = v % MOD; }; ModInt(): val(0) {} ModInt(ll v) { setval(v); }; ModInt operator+(const ModInt &x) const { return ModInt(val + x.val); } ModInt operator-(const ModInt &x) const { return ModInt(val - x.val + MOD); } ModInt operator*(const ModInt &x) const { return ModInt(val * x.val); } ModInt operator/(const ModInt &x) const { return *this * x.inv(); } ModInt operator-() const { return ModInt(MOD - val); } ModInt operator+=(const ModInt &x) { return *this = *this + x; } ModInt operator-=(const ModInt &x) { return *this = *this - x; } ModInt operator*=(const ModInt &x) { return *this = *this * x; } ModInt operator/=(const ModInt &x) { return *this = *this / x; } bool operator==(const ModInt &x) const { return (*this).val == x.val; } friend ostream& operator<<(ostream &os, const ModInt &x) { os << x.val; return os; } friend istream& operator>>(istream &is, ModInt &x) { is >> x.val; x.val = (x.val % MOD + MOD) % MOD; return is; } ModInt pow(ll n) const { ModInt a = 1; if(n == 0) return a; int i0 = 64 - __builtin_clzll(n); for(int i = i0 - 1; i >= 0; i--){ a = a * a; if((n >> i) & 1) a *= (*this); } return a; } ModInt inv() const { return this->pow(MOD - 2); } }; using mint = ModInt<mod>; mint pow(mint x, long long n) { return x.pow(n); } //using mint = double; //for debug using mvec = vector<mint>; using mmat = vector<mvec>; struct Combination{ vector<mint> fact, invfact; Combination(int N){ fact = vector<mint>({mint(1)}); invfact = vector<mint>({mint(1)}); fact_initialize(N); } void fact_initialize(int N){ int i0 = fact.size(); if(i0 >= N + 1) return; fact.resize(N + 1); invfact.resize(N + 1); for(int i = i0; i <= N; i++) fact[i] = fact[i - 1] * i; invfact[N] = (mint)1 / fact[N]; for(int i = N - 1; i >= i0; i--) invfact[i] = invfact[i + 1] * (i + 1); } mint nCr(int n, int r){ if(n < 0 || r < 0 || r > n) return mint(0); if(fact.size() < n + 1) fact_initialize(n); return fact[n] * invfact[r] * invfact[n - r]; } mint nPr(int n, int r){ if(n < 0 || r < 0 || r > n) return mint(0); if(fact.size() < n + 1) fact_initialize(n); return fact[n] * invfact[n - r]; } mint Catalan(int n){ if(n < 0) return 0; else if(n == 0) return 1; if(fact.size() < 2 * n + 1) fact_initialize(2 * n); return fact[2 * n] * invfact[n + 1] * invfact[n]; } }; signed main(){ int n; cin >> n; vec c(n); cin >> c; vec b(n - 1); cin >> b; int q; cin >> q; assert(q == 1); int x; cin >> x; vec p(n); p[n - 1] = 0; IREP(i, n - 1) p[i] = p[i + 1] + b[i]; const int M = 600000; int th = max(x + p[0], 0LL); mvec dp(M + 1, 0); FOR(j, p[0], c[0] + p[0] + 1) if(j >= th) dp[j] = 1; FOR(i, 1, n){ FOR(j, 1, M + 1) dp[j] += dp[j - 1]; IREP(j, M + 1){ int jmin = j - (p[i] + c[i]), jmax = j - p[i]; mint tmp = 0; if(jmax >= 0) tmp += dp[jmax]; if(jmin - 1 >= 0) tmp -= dp[jmin - 1]; dp[j] = tmp; } REP(j, (i + 1) * th) if(j <= M) dp[j] = 0; } mint ans = 0; REP(j, M + 1) ans += dp[j]; Out(ans); return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define trav(a, x) for(auto& a : x) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; const int N = 105; const int MOD = (int)1e9 + 7; struct mi { typedef decay<decltype(MOD)>::type T; /// don't silently convert to T T v; explicit operator T() const { return v; } mi() { v = 0; } mi(ll _v) { v = (-MOD < _v && _v < MOD) ? _v : _v % MOD; if (v < 0) v += MOD; } friend bool operator==(const mi& a, const mi& b) { return a.v == b.v; } friend bool operator!=(const mi& a, const mi& b) { return !(a == b); } friend bool operator<(const mi& a, const mi& b) { return a.v < b.v; } // friend void re(mi& a) { ll x; re(x); a = mi(x); } // friend str ts(mi a) { return ts(a.v); } mi& operator+=(const mi& m) { if ((v += m.v) >= MOD) v -= MOD; return *this; } mi& operator-=(const mi& m) { if ((v -= m.v) < 0) v += MOD; return *this; } mi& operator*=(const mi& m) { v = (ll)v*m.v%MOD; return *this; } mi& operator/=(const mi& m) { return (*this) *= inv(m); } friend mi pow(mi a, ll p) { mi ans = 1; assert(p >= 0); for (; p; p /= 2, a *= a) if (p&1) ans *= a; return ans; } friend mi inv(const mi& a) { assert(a.v != 0); return pow(a,MOD-2); } mi operator-() const { return mi(-v); } mi& operator++() { return *this += 1; } mi& operator--() { return *this -= 1; } friend mi operator+(mi a, const mi& b) { return a += b; } friend mi operator-(mi a, const mi& b) { return a -= b; } friend mi operator*(mi a, const mi& b) { return a *= b; } friend mi operator/(mi a, const mi& b) { return a /= b; } }; int n; int c[N], b[N]; int lb[N], psum[N]; mi dp[N][N * N]; mt19937 rng(2333); int main() { ios::sync_with_stdio(false); cin.tie(NULL); cin >> n; rep(i, 1, n + 1) cin >> c[i]; rep(i, 1, n) cin >> b[i]; int q; cin >> q; int x; cin >> x; lb[1] = psum[1] = x; rep(i, 2, n + 1) { lb[i] = lb[i - 1] + b[i - 1]; psum[i] = lb[i] + psum[i - 1]; } dp[0][0] = 1; int maxs = 100 * n; rep(i, 1, n + 1) { rep(s, psum[i], maxs + 1) { rep(cur, 0, min(s + 1, c[i] + 1)) { dp[i][s] += dp[i - 1][s - cur]; } } } mi res = 0; rep(i, 0, maxs + 1) res += dp[n][i]; cout << int(res) << endl; }
9
CPP
/*~Rainybunny~*/ #include <cstdio> #include <cstring> #define rep( i, l, r ) for ( int i = l, rep##i = r; i <= rep##i; ++i ) #define per( i, r, l ) for ( int i = r, per##i = l; i >= per##i; --i ) const int MAXN = 101, MOD = 1e9 + 7; int n, c[MAXN + 5], b[MAXN + 5]; int sc[MAXN + 5], sb[MAXN + 5], sb2[MAXN + 5]; int h[MAXN + 5], ans[MAXN + 5]; inline void chkmax( int& a, const int b ) { a < b && ( a = b ); } inline int imin( const int a, const int b ) { return a < b ? a : b; } inline int imax( const int a, const int b ) { return a < b ? b : a; } inline int sub( int a, const int b ) { return ( a -= b ) < 0 ? a + MOD : a; } inline int add( int a, const int b ) { return ( a += b ) < MOD ? a : a - MOD; } inline int solve( const int lim ) { static int f[MAXN * MAXN + 5], g[MAXN * MAXN + 5]; memset( f, 0, sizeof f ), f[0] = 1; rep ( i, 1, n ) { g[0] = f[0]; rep ( j, 1, sc[i] ) g[j] = add( g[j - 1], f[j] ); rep ( j, 0, lim * i + sb[i - 1] - 1 ) f[j] = 0; rep ( j, imax( 0, lim * i + sb[i - 1] ), sc[i] ) { f[j] = sub( g[j], j > c[i] ? g[j - c[i] - 1] : 0 ); } } int ret = 0; rep ( i, imax( 0, lim * n + sb[n - 1] ), sc[n] ) ret = add( ret, f[i] ); return ret; } int main() { scanf( "%d", &n ); rep ( i, 1, n ) scanf( "%d", &c[i] ), sc[i] = sc[i - 1] + c[i]; rep ( i, 1, n - 1 ) scanf( "%d", &b[i] ); int mx = 0xcfcfcfcf; rep ( i, 1, n ) sb[i] = sb[i - 1] + b[i]; rep ( i, 1, n ) sb[i] += sb[i - 1]; rep ( i, 1, n ) chkmax( mx, ( sb[i - 1] + i - 1 ) / i ); rep ( i, 0, MAXN ) ans[i] = solve( i - mx ); int q, x; scanf( "%d", &q ); while ( q-- ) { scanf( "%d", &x ), x = imin( MAXN - mx, imax( x, -mx ) ); printf( "%d\n", ans[x + mx] ); } return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;} template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int N; int C[101]; int B[101],S[101]; int Q; int X; const ll mo=1000000007; ll from[10101][2]; ll to[10101][2]; void solve() { int i,j,k,l,r,x,y; string s; cin>>N; FOR(i,N) cin>>C[i]; FOR(i,N-1) { cin>>x; B[i+1]=B[i]+x; S[i+1]=S[i]+B[i+1]; } cin>>Q; while(Q--) { cin>>X; from[0][0]=1; FOR(i,N) { ZERO(to); FOR(x,100*i+1) if(from[x][0]||from[x][1]) { FOR(y,C[i]+1) { (to[x+y][1]+=from[x][1])%=mo; if(x+y-S[i]-X*(i+1)<0) (to[x+y][1]+=from[x][0])%=mo; else (to[x+y][0]+=from[x][0])%=mo; } } swap(from,to); } ll ret=0; FOR(i,10100) ret+=from[i][0]; cout<<ret%mo<<endl; } } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); cout.tie(0); solve(); return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define x first #define y second typedef pair<int,int> pii; typedef long long ll; typedef unsigned long long ull; template <typename T> void chkmax(T &x,T y){x<y?x=y:T();} template <typename T> void chkmin(T &x,T y){y<x?x=y:T();} template <typename T> void readint(T &x) { x=0;int f=1;char c; for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1; for(;isdigit(c);c=getchar())x=x*10+(c-'0'); x*=f; } const int MOD=1000000007; inline int dmy(int x){return x>=MOD?x-MOD:x;} inline void inc(int &x,int y){x=dmy(x+y);} int qmi(int x,int y) { int ans=1; for(;y;y>>=1,x=1ll*x*x%MOD) if(y&1)ans=1ll*ans*x%MOD; return ans; } const int MAXN=105; int n,m,c[MAXN],b[MAXN],x[MAXN]; int f[MAXN][MAXN*MAXN]; int main() { #ifdef LOCAL freopen("code.in","r",stdin); // freopen("code.out","w",stdout); #endif readint(n); for(int i=1;i<=n;++i)readint(c[i]); for(int i=2;i<=n;++i)readint(b[i]),b[i]+=b[i-1]; readint(m); for(int i=1;i<=m;++i)readint(x[i]); int sum=0,pre=0; f[0][0]=1; for(int i=1;i<=n;++i) { for(int j=max(sum,0);j<=pre;++j) for(int k=0;k<=c[i];++k) inc(f[i][j+k],f[i-1][j]); sum+=b[i]+x[1]; pre+=c[i]; } int res=0; for(int j=max(sum,0);j<=pre;++j) inc(res,f[n][j]); printf("%d\n",res); return 0; }
9
CPP
// Bhagya Kamal Jain #include<bits/stdc++.h> #define ll long long #define pb push_back #define endl '\n' #define mii map<ll int,ll int> #define pii pair<ll int,ll int> #define vi vector<ll int> #define all(a) (a).begin(),(a).end() #define F first #define S second #define hell 1000000007 #define sim template < class c #define ris return * this #define dor > debug & operator << #define eni(x) sim > typename \ enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) { using namespace std; sim > struct rge {c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cout << *x, 0); sim > char dud(...); struct debug { ~debug() { cout<<endl; } eni(!=) cout << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } }; #define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " #define N 10005 ll int dp[N]; ll int tmp[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int TESTS=1; // cin>>TESTS; while(TESTS--) { ll int n; cin >> n; ll int c[n + 1]; for(ll int i = 1; i <= n; i++) cin >> c[i]; ll int b[n]; for(ll int i = 1; i < n; i++) cin >> b[i]; ll int q; cin >> q; while(q--) { ll int x; cin >> x; ll int arr[n + 1]; arr[1] = x; for(ll int i = 2; i <= n; i++) { arr[i] = arr[i - 1] + b[i - 1]; } ll int val[n + 1]; val[0] = 0; for(ll int i = 1; i <= n; i++) { val[i] = val[i - 1] + arr[i]; } dp[0] = 1; for(ll int i = 1; i <= n; i++) { for(ll int j = 0; j < N; j++) { tmp[j] = dp[j]; } memset(dp, 0, sizeof(dp)); for(ll int j = 0; j < N; j++) { for(ll int k = 0; k <= c[i]; k++) { if(k + j < N) dp[k + j] = (dp[k + j] + tmp[j]) % hell; } } for(ll int j = 0; j < N; j++) { if(j < val[i]) dp[j] = 0; } } ll int ans = 0; for(ll int j = 0; j < N; j++) { ans = (ans + dp[j]) % hell; } cout << ans << endl; } } return 0; }
9
CPP
#include <unordered_map> #include <algorithm> #include <iostream> #include <cstdlib> #include <fstream> #include <random> #include <iomanip> #include <clocale> #include <bitset> #include <string> #include <vector> #include <cmath> #include <ctime> #include <stack> #include <queue> #include <deque> #include <set> #include <map> using namespace std; #define endl '\n' #define int long long const int MOD = 1000000007; const int INF = 2000000000; const int MAXN = 100000; int dp[100][20000]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> c(n); for (int i = 0; i < n; i++) { cin >> c[i]; } vector<int> b(n); for (int i = 1; i < n; i++) { cin >> b[i]; } vector<int> bp(n); for (int i = 1; i < n; i++) { bp[i] = bp[i - 1] + b[i]; } for (int i = 1; i < n; i++) { bp[i] += bp[i - 1]; } int q; cin >> q; for (int _ = 0; _ < q; _++) { int x; cin >> x; vector<int> need(n); for (int i = 0; i < n; i++) { need[i] = bp[i] + x * (i + 1); } for (int i = 0; i < 100; i++) { for (int j = 0; j <= 10000; j++) { dp[i][j] = 0; } } for (int i = max(0LL, need[0]); i <= c[0]; i++) { dp[0][i] = 1; } for (int i = 1; i < n; i++) { for (int j = need[i]; j <= 10000; j++) { for (int k = 0; k <= c[i]; k++) { if (j < k) { break; } dp[i][j] += dp[i - 1][j - k]; if (dp[i][j] >= MOD) { dp[i][j] -= MOD; } } } } int ans = 0; for (int j = 0; j <= 10000; j++) { ans += dp[n - 1][j]; } cout << ans % MOD; } }
9
CPP
#include<bits/stdc++.h> namespace my_std{ using namespace std; #define pii pair<int,int> #define fir first #define sec second #define MP make_pair #define rep(i,x,y) for (int i=(x);i<=(y);i++) #define drep(i,x,y) for (int i=(x);i>=(y);i--) #define go(x) for (int i=head[x];i;i=edge[i].nxt) #define templ template<typename T> #define sz 111 #define mod 1000000007ll typedef long long ll; typedef double db; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);} templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;} templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;} templ inline void read(T& t) { t=0;char f=0,ch=getchar();double d=0.1; while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar(); while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar(); if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();} t=(f?-t:t); } template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);} char __sr[1<<21],__z[20];int __C=-1,__zz=0; inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;} inline void print(int x) { if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x; while(__z[++__zz]=x%10+48,x/=10); while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n'; } void file() { #ifdef NTFOrz freopen("a.in","r",stdin); #endif } inline void chktime() { #ifdef NTFOrz cerr<<clock()/1000.0<<'\n'; #endif } #ifdef mod ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;} ll inv(ll x){return ksm(x,mod-2);} #else ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;} #endif // inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;} } using namespace my_std; int n; int c[sz],b[sz],B[sz]; ll pre[sz][sz*sz],pr; void init() { pre[0][0]=1; rep(i,0,n-1) rep(k,0,100*i) rep(t,0,c[i+1]) (pre[i+1][k+t]+=pre[i][k])%=mod; pr=1; rep(i,1,n) pr=pr*(c[i]+1)%mod; } ll dp[sz][sz*sz]; ll work(int x) { static int lim[sz]; rep(i,1,n) lim[i]=i*x+B[i]; int p=1; while (p<=n&&lim[p]<=0) ++p; if (p>n) return pr; rep(i,p,n) rep(j,0,i*100) dp[i][j]=0; rep(i,lim[p],p*100) dp[p][i]=pre[p][i]; rep(i,p,n-1) { rep(k,lim[i],i*100) { int l=k,r=k+c[i+1]; if (r<lim[i+1]) continue; chkmax(l,lim[i+1]); dp[i+1][l]+=dp[i][k],dp[i+1][r+1]+=mod-dp[i][k]; } dp[i+1][lim[i+1]]%=mod; rep(k,lim[i+1]+1,(i+1)*100) (dp[i+1][k]+=dp[i+1][k-1])%=mod; } ll res=0; rep(i,lim[n],n*100) res+=dp[n][i]; return res%mod; } int main() { file(); read(n); rep(i,1,n) read(c[i]); rep(i,2,n) read(b[i]),B[i]=b[i]+B[i-1]; rep(i,2,n) B[i]+=B[i-1]; init(); int Q; read(Q); map<int,ll>vis; while (Q--) { int x; read(x); if (x>100) { puts("0"); continue; } if (x<-6000) { printf("%lld\n",pr); continue; } if (vis.count(x)) { printf("%lld\n",vis[x]); continue; } ll ans=work(x); printf("%lld\n",vis[x]=ans); } return 0; }
9
CPP
#include <bits/stdc++.h> // #pragma GCC optimize("trapv") #define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0); #define F first #define S second #define V vector #define PB push_back #define MP make_pair #define EB emplace_back #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m"; void DBG() { cerr << "]" << _reset << endl; } template<class H, class...T> void DBG(H h, T ...t) { cerr << to_string(h); if(sizeof ...(t)) cerr << ", "; DBG(t...); } #ifdef CHEISSMART #define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__) #else #define debug(...) #endif const int INF = 1e9 + 7, N = 105, M = 1e9 + 7; int c[N], b[N], at_least[N], dp[N][N*N]; void add(int& a, int b) { a += b; if(a >= M) a -= M; } signed main() { IO_OP; mt19937 rng(time(0)); int n; cin >> n; // n = 100; for(int i = 1; i <= n; i++) { cin >> c[i]; // c[i] = rng() % 101; } for(int i = 1; i <= n - 1; i++) { cin >> b[i]; // b[i] = rng() % 101; } int q, x; cin >> q >> x; // q = 1, x = rng() % int(2e5) - 1e5; assert(q == 1); for(int i = 1; i <= n; i++) { at_least[i] = i * x; for(int j = 1; j <= i; j++) for(int k = 1; k < j; k++) at_least[i] += b[k]; at_least[i] = max(at_least[i], 0); } dp[0][0] = 1; for(int i = 0; i < n; i++) { for(int j = at_least[i]; j < N * N; j++) if(dp[i][j]) { int need = max(at_least[i + 1] - j, 0); for(int k = need; k <= c[i + 1]; k++) { add(dp[i + 1][j + k], dp[i][j]); } } } int ans = 0; for(int j = 0; j < N * N; j++) add(ans, dp[n][j]); cout << ans << '\n'; }
9
CPP
#include <bits/stdc++.h> using namespace std; #define ll long long #define int ll #define ld long double #define pii pair<int, int> #define f first #define s second #define boost() cin.tie(0), cin.sync_with_stdio(0) const int MN = 105, MOD = 1e9 + 7; int n, a[MN], b[MN], c[MN], psa[MN], psum[MN], q, x, dp[12000005], ndp[12000005]; int32_t main() { boost(); cin >> n; for (int i = 1; i <= n; i++) cin >> c[i], psa[i] = psa[i - 1] + c[i]; for (int i = 1; i < n; i++) cin >> b[i]; cin >> q >> x; int sum = 0; a[1] = x; for (int i = 2; i <= n; i++) a[i] = a[i - 1] + b[i - 1]; for (int i = 1; i <= n; i++) sum += a[i], psum[i] = psum[i - 1] + a[i]; //printf("%lld\n", sum); //if (x > c[1]) return 0 * printf("0\n"); int ans = 0; dp[0] = 1; for (int i = 1; i <= n; i++) { for (int j = 0; j <= psa[i - 1]; j++) { int lo = 0, hi = c[i]; //if (i == 1) lo = max(lo, x); ndp[j + lo] += dp[j]; ndp[j + lo] %= MOD; ndp[j + hi + 1] -= dp[j]; ndp[j + hi + 1] %= MOD; } for (int j = 1; j <= psa[i]; j++) { ndp[j] += ndp[j - 1]; ndp[j] %= MOD; } for (int j = 0; j <= psa[i]; j++) { dp[j] = ndp[j]; if (j < psum[i]) dp[j] = 0; } //printf("\n"); for (int j = 0; j <= psa[i] + 1; j++) { ndp[j] = 0; } } for (int i = 0; i <= psa[n]; i++) ans += dp[i], ans %= MOD; ans %= MOD, ans += MOD, ans %= MOD; printf("%lld\n", ans); return 0; }
9
CPP
/*{{{*/ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<string> #include<iostream> #include<sstream> #include<set> #include<map> #include<queue> #include<bitset> #include<vector> #include<limits.h> #include<assert.h> #define SZ(X) ((int)(X).size()) #define ALL(X) (X).begin(), (X).end() #define REP(I, N) for (int I = 0; I < (N); ++I) #define REPP(I, A, B) for (int I = (A); I < (B); ++I) #define FOR(I, A, B) for (int I = (A); I <= (B); ++I) #define FORS(I, S) for (int I = 0; S[I]; ++I) #define RS(X) scanf("%s", (X)) #define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end())))) #define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin()) #define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++) #define MP make_pair #define PB emplace_back #define MS0(X) memset((X), 0, sizeof((X))) #define MS1(X) memset((X), -1, sizeof((X))) #define LEN(X) strlen(X) #define F first #define S second using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef long double LD; typedef pair<int,int> PII; typedef vector<int> VI; typedef vector<LL> VL; typedef vector<PII> VPII; typedef pair<LL,LL> PLL; typedef vector<PLL> VPLL; template<class T> void _R(T &x) { cin >> x; } void _R(int &x) { scanf("%d", &x); } void _R(int64_t &x) { scanf("%lld", &x); } void _R(double &x) { scanf("%lf", &x); } void _R(char &x) { scanf(" %c", &x); } void _R(char *x) { scanf("%s", x); } void R() {} template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); } template<class T> void _W(const T &x) { cout << x; } void _W(const int &x) { printf("%d", x); } void _W(const int64_t &x) { printf("%lld", x); } void _W(const double &x) { printf("%.16f", x); } void _W(const char &x) { putchar(x); } void _W(const char *x) { printf("%s", x); } template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);} template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); } void W() {} template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); } #ifdef HOME #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);} #else #define DEBUG(...) #endif int MOD = 1e9+7;/*}}}*/ void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;} const int SIZE = 1<<20; int c[SIZE],b[SIZE]; int n; LL dp[SIZE]; LL bk_num[SIZE]; void solve() { int q; R(q); bk_num[n]=1; for(int i=n-1;i>=0;i--){ bk_num[i]=bk_num[i+1]*(c[i+1]+1)%MOD; } while(q--){ int x; R(x); LL an=0; dp[0]=1; int now=0; LL sb=0; LL d=0; FOR(i,1,n){ for(int j=now;j>=0;j--){ if(dp[j]){ LL me=dp[j]; dp[j]=0; for(int k=c[i];k>=0;k--){ int v=j+k; if(i*x+d>v){ ADD(an,bk_num[i]*me); }else{ ADD(dp[j+k],me); } } } } now+=c[i]; sb+=b[i]; d+=sb; } an=bk_num[0]-an; ADD(an,0); W(an); } } void input() { R(n); FOR(i,1,n)R(c[i]); FOR(i,1,n-1)R(b[i]); } int main(){ input(); solve(); return 0; }
9
CPP
/* Author: QAQAutoMaton Lang: C++ Code: C1.cpp Mail: [email protected] Blog: https://www.qaq-am.com/ */ #include<bits/stdc++.h> #define debug(qaq...) fprintf(stderr,qaq) #define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__) #define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__) #define all(x) x.begin(),x.end() #define x first #define y second #define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end()) using namespace std; typedef unsigned uint; typedef long long ll; typedef unsigned long long ull; typedef complex<double> cp; typedef pair<int,int> pii; int inf; const double eps=1e-8; const double pi=acos(-1.0); template<class T,class T2>int chkmin(T &a,T2 b){return a>b?a=b,1:0;} template<class T,class T2>int chkmax(T &a,T2 b){return a<b?a=b,1:0;} template<class T>T sqr(T a){return a*a;} template<class T,class T2>T mmin(T a,T2 b){return a<b?a:b;} template<class T,class T2>T mmax(T a,T2 b){return a>b?a:b;} template<class T>T aabs(T a){return a<0?-a:a;} template<class T>int dcmp(T a,T b){return a>b;} template<int *a>int cmp_a(int x,int y){return a[x]<a[y];} template<class T>bool sort2(T &a,T &b){return a>b?swap(a,b),1:0;} #define min mmin #define max mmax #define abs aabs struct __INIT__{ __INIT__(){ fill((unsigned char*)&inf,(unsigned char*)&inf+sizeof(inf),0x3f); } }__INIT___; namespace io { const int SIZE = (1 << 21) + 1; char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr; // getchar #define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++) // print the remaining part inline void flush () { fwrite (obuf, 1, oS - obuf, stdout); oS = obuf; } // putchar inline void putc (char x) { *oS ++ = x; if (oS == oT) flush (); } template<typename A> inline bool read (A &x) { for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;else if(c==EOF)return 0; for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f; return 1; } inline bool read (char &x) { while((x=gc())==' '||x=='\n' || x=='\r'); return x!=EOF; } inline bool read(char *x){ while((*x=gc())=='\n' || *x==' '||*x=='\r'); if(*x==EOF)return 0; while(!(*x=='\n'||*x==' '||*x=='\r'||*x==EOF))*(++x)=gc(); *x=0; return 1; } template<typename A,typename ...B> inline bool read(A &x,B &...y){ return read(x)&&read(y...); } template<typename A> inline bool write (A x) { if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x; while (x) qu[++ qr] = x % 10 + '0', x /= 10; while (qr) putc (qu[qr --]); return 0; } inline bool write (char x) { putc(x); return 0; } inline bool write(const char *x){ while(*x){putc(*x);++x;} return 0; } inline bool write(char *x){ while(*x){putc(*x);++x;} return 0; } template<typename A,typename ...B> inline bool write(A x,B ...y){ return write(x)||write(y...); } //no need to call flush at the end manually! struct Flusher_ {~Flusher_(){flush();}}io_flusher_; } using io :: read; using io :: putc; using io :: write; const int p=1000000007; struct Z{ uint x; Z(){} Z(uint a){ x=a; } }; inline uint modp(const uint x){ return x<p?x:x-p; } inline Z operator+(const Z x1, const Z x2) { return modp(x1.x+x2.x);} inline Z operator-(const Z x1, const Z x2) { return modp(x1.x+p-x2.x);} inline Z operator-(const Z x) {return x.x?p-x.x:0;} inline Z operator*(const Z x1, const Z x2) { return static_cast<ull>(x1.x)*x2.x%p;} void exgcd(int a,int b,int &x,int &y){ if(!b){x=1;y=0;return;} exgcd(b,a%b,y,x); y-=(a/b)*x; } inline Z Inv(const Z a){ int x,y; exgcd(p,a.x,x,y); return y<0?y+=p:y; } inline Z operator/(const Z x1, const Z x2) { return x1*Inv(x2);} inline Z &operator++(Z &x1){x1.x==p-1?x1.x=0:++x1.x;return x1;} inline Z &operator--(Z &x1){x1.x?--x1.x:x1.x=p-1;return x1;} inline Z &operator+=(Z &x1, const Z x2) { return x1 = x1 + x2; } inline Z &operator-=(Z &x1, const Z x2) { return x1 = x1 - x2; } inline Z &operator*=(Z &x1, const Z x2) { return x1 = x1 * x2; } inline Z &operator/=(Z &x1, const Z x2) { return x1 = x1 / x2; } inline Z fpm(Z a,int b){Z c(1);for(;b;b>>=1,a*=a)if(b&1)c*=a;return c;} int c[105],b[105]; Z f[10005],g[10005]; int w[105]; signed main(){ #ifdef QAQAutoMaton freopen("C1.in","r",stdin); freopen("C1.out","w",stdout); #endif int n; read(n); int l=0; for(int i=1;i<=n;++i){ read(c[i]); } for(int i=l;~i;--i)f[i]+=f[i+1]; for(int i=1;i<n;++i){ read(b[i]); } int ss=0; for(int i=2;i<=n;++i){ ss+=b[i-1]; w[i]=w[i-1]+ss; } int q; read(q); int x; for(;q;--q){ read(x); for(int i=0;i<=l;++i)f[i]=0; f[0]=1; l=0; for(int i=1;i<=n;++i){ g[0]=f[0]; l+=c[i]; for(int j=1;j<=l;++j)g[j]=f[j]+g[j-1]; for(int j=0;j<=l;++j){ f[j]=g[j]-(j>c[i]?g[j-c[i]-1]:0); } for(int j=0;j<=l;++j){ if(x*i+w[i]>j)f[j]=0; } } Z ans(0); for(int i=0;i<=l;++i)ans+=f[i]; write(ans.x,'\n'); } return 0; }
9
CPP
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int mod=1e9+7; inline int addmod(int x) { return x>=mod?x-mod:x; } inline int submod(int x) { return x<0?x+mod:x; } int n,m,q,b[105],c[105],sum[105],f[105][10005],qans[1005],pn; int solve(int x) { memset(f,0,sizeof(f)); f[0][0]=1; int nw=0,ans=0; for(int i=1;i<=n;i++) { for(int j=0;j<=nw;j++) { f[i][j]=addmod(f[i][j]+f[i-1][j]); f[i][j+c[i]+1]=submod(f[i][j+c[i]+1]-f[i-1][j]); } nw+=c[i]; for(int j=1;j<=nw;j++) f[i][j]=addmod(f[i][j]+f[i][j-1]); for(int j=0;j<x*i+sum[i];j++) f[i][j]=0; } for(int i=0;i<=nw;i++) ans=addmod(ans+f[n][i]); return ans; } int main() { scanf("%d",&n); int mul=1; for(int i=1;i<=n;i++) { scanf("%d",&c[i]); m=max(m,c[i]); mul=1ll*mul*(c[i]+1)%mod; } for(int i=1;i<n;i++) scanf("%d",&b[i]); for(int i=1;i<=n;i++) for(int j=1;j<i;j++) sum[i]+=(i-j)*b[j]; pn=(-sum[n])/n; for(int i=0;i<=m;i++) qans[i]=solve(i+pn); scanf("%d",&q); for(int i=1;i<=q;i++) { int x; scanf("%d",&x); if(x<pn) printf("%d\n",mul); else if(x>pn+m) printf("0\n"); else printf("%d\n",qans[x-pn]); } return 0; }
9
CPP
#include <stdio.h> #include <iostream> #include <string> #include <string.h> #include <vector> #include <cmath> #include <assert.h> #include <algorithm> #include <queue> #include <climits> #include <set> #include <unordered_map> #include <time.h> #include <map> #include <stack> #include <unordered_set> #include <bitset> #define hash hassh using namespace std; int c[105],b[105]; long long dp[105][10005]; int preb[105]; int main() { int T = 1; //cin >> T; while (T--) { int n,q,x; cin>>n; for(int i=1;i<=n;i++) cin>>c[i]; for(int i=1;i<n;i++) cin>>b[i]; cin>>q>>x; for(int i=2;i<=n;i++){ preb[i]=preb[i-1]; for(int j=1;j<i;j++) preb[i]+=b[j]; } long long ans=0,mod=1000000007; dp[0][0]=1; for(int i=1;i<=n;i++){ int mn=i*x+preb[i]; for(int j=max(mn,0);j<=i*100;j++){ for(int k=0;k<=c[i];k++) if(j>=k) dp[i][j]+=dp[i-1][j-k],dp[i][j]%=mod; if(i==n) ans+=dp[i][j],ans%=mod; } } printf("%lld\n",ans); } return 0; } //注意检查边界 //注意考虑某些数组/向量可能为空 可能引起错误 //注意各种边界是0还是1 //注意少加不必要的限制条件 避免出错 //不要把前期题想得太难,尝试找简单结论 //想想直接套路化dp行不行! //求倍增要一层一层求不要一项一项求!!!!
9
CPP
#include <bits/stdc++.h> using namespace std; static struct FastInput { static constexpr int BUF_SIZE = 1 << 20; char buf[BUF_SIZE]; size_t chars_read = 0; size_t buf_pos = 0; FILE *in = stdin; char cur = 0; inline char get_char() { if (buf_pos >= chars_read) { chars_read = fread(buf, 1, BUF_SIZE, in); buf_pos = 0; buf[0] = (chars_read == 0 ? -1 : buf[0]); } return cur = buf[buf_pos++]; } inline void tie(int) {} inline explicit operator bool() { return cur != -1; } inline static bool is_blank(char c) { return c <= ' '; } inline bool skip_blanks() { while (is_blank(cur) && cur != -1) { get_char(); } return cur != -1; } inline FastInput& operator>>(char& c) { skip_blanks(); c = cur; return *this; } inline FastInput& operator>>(string& s) { if (skip_blanks()) { s.clear(); do { s += cur; } while (!is_blank(get_char())); } return *this; } template <typename T> inline FastInput& read_integer(T& n) { // unsafe, doesn't check that characters are actually digits n = 0; if (skip_blanks()) { int sign = +1; if (cur == '-') { sign = -1; get_char(); } do { n += n + (n << 3) + cur - '0'; } while (!is_blank(get_char())); n *= sign; } return *this; } template <typename T> inline typename enable_if<is_integral<T>::value, FastInput&>::type operator>>(T& n) { return read_integer(n); } #if !defined(_WIN32) || defined(_WIN64) inline FastInput& operator>>(__int128& n) { return read_integer(n); } #endif template <typename T> inline typename enable_if<is_floating_point<T>::value, FastInput&>::type operator>>(T& n) { // not sure if really fast, for compatibility only n = 0; if (skip_blanks()) { string s; (*this) >> s; sscanf(s.c_str(), "%lf", &n); } return *this; } } fast_input; #define cin fast_input static struct FastOutput { static constexpr int BUF_SIZE = 1 << 20; char buf[BUF_SIZE]; size_t buf_pos = 0; static constexpr int TMP_SIZE = 1 << 20; char tmp[TMP_SIZE]; FILE *out = stdout; inline void put_char(char c) { buf[buf_pos++] = c; if (buf_pos == BUF_SIZE) { fwrite(buf, 1, buf_pos, out); buf_pos = 0; } } ~FastOutput() { fwrite(buf, 1, buf_pos, out); } inline FastOutput& operator<<(char c) { put_char(c); return *this; } inline FastOutput& operator<<(const char* s) { while (*s) { put_char(*s++); } return *this; } inline FastOutput& operator<<(const string& s) { for (int i = 0; i < (int) s.size(); i++) { put_char(s[i]); } return *this; } template <typename T> inline char* integer_to_string(T n) { // beware of TMP_SIZE char* p = tmp + TMP_SIZE - 1; if (n == 0) { *--p = '0'; } else { bool is_negative = false; if (n < 0) { is_negative = true; n = -n; } while (n > 0) { *--p = (char) ('0' + n % 10); n /= 10; } if (is_negative) { *--p = '-'; } } return p; } template <typename T> inline typename enable_if<is_integral<T>::value, char*>::type stringify(T n) { return integer_to_string(n); } #if !defined(_WIN32) || defined(_WIN64) inline char* stringify(__int128 n) { return integer_to_string(n); } #endif template <typename T> inline typename enable_if<is_floating_point<T>::value, char*>::type stringify(T n) { sprintf(tmp, "%.17f", n); return tmp; } template <typename T> inline FastOutput& operator<<(const T& n) { auto p = stringify(n); for (; *p != 0; p++) { put_char(*p); } return *this; } } fast_output; // here puts define typedef long long ll; typedef long double ld; typedef unsigned long long ull; #define rint register int #define rll register ll #define pii pair<int, int> #define pll pair<ll, ll> #define fors(i, a, b) for (ll i = (a); i <= (b); ++i) #define _fors(i, a, b) for (ll i = (a); i >= (b); --i) #define cyc(m) fors(rqtwqtqwt, 1, m) #define mp(a, b) make_pair(a, b) #define mt(a, b, c) make_tuple(a, b, c) #define mem(A, b) memset(A, b, sizeof(A)) #define all(X) (X).begin(), (X).end() #define y0 gawgfawgawg #define y1 sdfyseyegeh #define pb push_back #define eb emplace_back #define cout fast_output #define endl '\n' #define yes cout << "YES" << endl #define no cout << "NO" << endl #define int long long int start_time; const int _ = 105; const int mod = 1e9 + 7; const int inv2 = (mod + 1) / 2; inline int add(int a, int b) { return (((a + b) % mod) + mod) % mod; } inline int mul(int a, int b) { return 1ll * a * b % mod; } int n, q; int b[_], c[_]; int dp[_*_], s[_*_]; int sum[_]; int m; void solve() { cin >> n; fors(i, 1, n) cin >> c[i]; fors(i, 1, n - 1) cin >> b[i]; fors(i, 2, n) { sum[i] = sum[i-1]; fors(j, 1, i - 1) sum[i] += b[j]; } // cout << '*' << m << endl; cin >> q; while (q--) { int xx; cin >> xx; dp[0] = 1; fors(i, 0, 10000) s[i] = 1; fors(id, 1, n) { fors(i, 0, 10000) { if (i <= c[id]) dp[i] = s[i]; else dp[i] = add(s[i], -s[i-c[id]-1]); } fors(i, 0, min(10000ll, id * xx + sum[id] - 1)) dp[i] = 0; s[0] = dp[0]; fors(i, 1, 10000) s[i] = add(s[i-1], dp[i]); } cout << s[10000] << endl; } return ; } signed main() { #ifdef Sakuyalove freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif ios::sync_with_stdio(false); cin.tie(0); start_time = clock(); int T = 1; // cin >> T; while (T--) { solve(); } #ifdef Sakuyalove cout << "time = " << clock() - start_time << endl; #endif return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; #define int long long constexpr int MAXN = 100; constexpr int MOD = 1000000007; constexpr int MAXTOLERANCE = 10000001; //10001; // really? TODO int c[MAXN], b[MAXN], magic[MAXN]; int dp1[MAXTOLERANCE], dp2[MAXTOLERANCE]; int coalesce[MAXTOLERANCE+1]; int* const coal=coalesce+MAXTOLERANCE/2; int32_t main(){ ios_base::sync_with_stdio(false); int n,q; cin>>n; for (int i=0;i<n;++i){ cin>>c[i]; } for(int i=1;i<n;++i){ cin>>b[i]; } cin>>q; for(int j=0;j<q;++j){ int x; cin>>x; /*if (x>MAXN){ cout<<0<<'\n'; continue; }*/ magic[0]=x; for(int i=1;i<n;++i){ magic[i]=magic[i-1]+b[i]; } int* prev=dp1+MAXTOLERANCE/2; fill_n(prev-MAXTOLERANCE/2, MAXTOLERANCE, 0); prev[x]=1; int prev_low=x; int prev_high=x; int* curr=dp2+MAXTOLERANCE/2; fill_n(curr-MAXTOLERANCE/2, MAXTOLERANCE, 0); for(int i=0;i<n-1;++i){ //fill_n(curr-MAXTOLERANCE/2, MAXTOLERANCE, 0); //fill_n(coal-MAXTOLERANCE/2, MAXTOLERANCE+1, 0); // TODO: optimize int coal_low=LLONG_MAX; int coal_high=LLONG_MIN; for(int k=prev_low;k<=prev_high;++k){ int start = max(k, 0ll); if (start <= c[i] && prev[k]>0){ int c_start = min(max(magic[i+1]-(c[i]-k), -MAXTOLERANCE/2), MAXTOLERANCE/2+1); int c_end = min(max(magic[i+1]-(start-k)+1, -MAXTOLERANCE/2), MAXTOLERANCE/2+1); coal[c_start]+=prev[k]; coal[c_start]%=MOD; coal[c_end]+=(MOD-prev[k]); coal[c_end]%=MOD; coal_low=min(coal_low,c_start); coal_high=max(coal_high,c_end-1); } /*for(int kk=start;kk<=c[i];++kk){ int ind = magic[i+1]-(kk-k); if (ind >= -MAXTOLERANCE/2 && ind <= MAXTOLERANCE/2){ curr[ind]+=prev[k]; curr[ind]%=MOD; } }*/ } int cum=0; for(int k=coal_low;k<=coal_high;++k){ cum+=coal[k]; cum%=MOD; curr[k]=cum; } fill(coal+coal_low,coal+coal_high+2,0); fill(prev+prev_low, prev+prev_high+1,0); prev_low=coal_low; prev_high=coal_high; swap(prev, curr); /*for(int k=-10;k<=10;++k){ cout<<' '<<prev[k]; } cout<<endl; cout<< prev_low<<' '<<prev_high<<endl;*/ } int ans=0; { //fill_n(curr-MAXTOLERANCE/2, MAXTOLERANCE, 0); // TODO: optimize for(int k=-MAXTOLERANCE/2;k<=MAXTOLERANCE/2;++k){ int start = max(k, 0ll); for(int kk=start;kk<=c[n-1];++kk){ ans+=prev[k]; ans%=MOD; } } } cout<<ans<<'\n'; } }
9
CPP
#include <bits/stdc++.h> using namespace std; int main() { double n, x, y, p, q, r; int a; cin >> n >> x >> y; p = y / 100; q = n * p; r = q - x; a = r; if (r > a) { cout << a + 1; } else if (a < 0) { cout << "0"; } else { cout << a; } }
7
CPP
num,wiz,per = map(int,input().split()) k = 0 while (k+wiz)/num*100 < per: k += 1 print(k)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { double n, x, y; cin >> n >> x >> y; if (y * n / 100 <= x) cout << 0; else cout << ceil(y * n / 100 - x); return 0; }
7
CPP
# https://codeforces.com/problemset/problem/168/A # 900 n, x, y = map(int, input().split()) y /= 100 c = 0 while True: if (x+c) / n >= y: break c += 1 print(c)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { int n, x, y; cin >> n >> x >> y; if ((ceil(y * n / 100.0) - x) < 0) cout << 0 << endl; else cout << ceil(y * n / 100.0) - x << endl; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n, x, y, c = 0; cin >> n >> x >> y; double p = ceil((y * n) / 100.00); p = (int)p; c = p - x; if (c <= 0) c = 0; cout << c; cout << '\n'; ; return 0; }
7
CPP
import math n,x,y=map(int,input().split()) z=math.ceil((y/100)*n) if(x>=z): print(0) else: print(z-x)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); float n, x, y; cin >> n >> x >> y; int ans = ceil((y * n / 100) - x); cout << max(ans, 0); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; while (cin >> n >> x >> y) { int sum = n * y; if (sum % 100) sum += 100; sum /= 100; sum -= x; if (sum > 0) cout << sum << endl; else cout << 0 << endl; } return 0; }
7
CPP
z=input mod = 10**9 + 7 from collections import * from queue import * from sys import * from collections import * from math import * from heapq import * from itertools import * from bisect import * from collections import Counter as cc from math import factorial as f def lcd(xnum1,xnum2): return (xnum1*xnum2//gcd(xnum1,xnum2)) ################################################################################ """ n=int(z()) for _ in range(int(z())): x=int(z()) l=list(map(int,z().split())) n=int(z()) l=sorted(list(map(int,z().split())))[::-1] a,b=map(int,z().split()) l=set(map(int,z().split())) led=(6,2,5,5,4,5,6,3,7,6) vowel={'a':0,'e':0,'i':0,'o':0,'u':0} color-4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ] """ ###########################---START-CODING---############################################### for _ in range(1): n,x,y=map(int,input().split()) w=x m=n-x t=ceil(n*y/100) print(max(0,t-x))
7
PYTHON3
#include <bits/stdc++.h> int main() { int n, x, y; scanf("%d", &n); scanf("%d", &x); scanf("%d", &y); int dy = 0; if ((y * n) % 100 == 0) dy = ((y * n) / 100); else dy = ((y * n) / 100) + 1; int ans = 0; if (dy - x <= 0) ans = 0; else ans = dy - x; printf("%d", ans); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int n, x, y; int main() { scanf("%d%d%d", &n, &x, &y); int req = (int)ceil((double)(n * y) / 100); if (req <= x) printf("%d\n", 0); else printf("%d\n", req - x); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main(void) { int citizens, wizards, percentage, result; scanf("%d %d %d", &citizens, &wizards, &percentage); result = ceil((percentage * citizens) / 100.0); result = max(result - wizards, 0); printf("%d\n", result); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; if ((ceil(n * (y / 100.0)) - x) <= 0) cout << 0 << endl; else cout << (ceil(n * (y / 100.0)) - x) << endl; }
7
CPP
import math n , x , y = map(int, input().split()) percentage = math.ceil(y*n/100) print(max(0, percentage-x))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; cout << max(0, (n * y + 99) / 100 - x) << endl; return 0; }
7
CPP
""" n=int(z()) for _ in range(int(z())): x=int(z()) l=list(map(int,z().split())) n=int(z()) l=sorted(list(map(int,z().split())))[::-1] a,b=map(int,z().split()) l=set(map(int,z().split())) led=(6,2,5,5,4,5,6,3,7,6) vowel={'a':0,'e':0,'i':0,'o':0,'u':0} color4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ] """ #!/usr/bin/env python #pyrival orz import os import sys from io import BytesIO, IOBase input = sys.stdin.readline ############ ---- Input Functions ---- ############ def inp(): return(int(input())) def inlt(): return(list(map(int,input().split()))) def insr(): s = input() return(list(s[:len(s) - 1])) def invr(): return(map(int,input().split())) from math import ceil def main(): try: n, x, y = invr() print(max(0, ceil((y*n)/100) - x)) except Exception as e: print(e) # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") # endregion if __name__ == "__main__": main()
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; float p = x * 100 / n; int i = 0; while (p < y) { i++; x++; p = x * 100 / n; } cout << i << endl; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { double n, x; double y; cin >> n >> x >> y; if ((x * 100) / n >= y) { cout << 0; exit(0); } cout << ceil((y * n) / 100 - x); }
7
CPP
#include <bits/stdc++.h> using namespace std; class Solution {}; int main(int argc, char* argv[]) { ios_base::sync_with_stdio(false); int n, x, y; cin >> n >> x >> y; double p = (((double)(y * n)) / 100.0 - x); if (p < 0) p = 0; cout << ceil(p) << "\n"; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { double n, x, y; cin >> n >> x >> y; double t = x / n; int ans = 0; while (t + 1e-7 < y / 100) { ans++; t = (x + ans) / n; } cout << ans; return 0; }
7
CPP
import math n,x,y=map(int,input().split()) d=math.ceil((y/100)*n) if(int(d)>x): print(int(d)-x) elif(int(d)<=x): print(0)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; y = ceil((y * n) / 100.0); cout << max(y - x, 0) << endl; ; }
7
CPP
#include <bits/stdc++.h> int main() { int n, x, y, m; scanf("%d %d %d", &n, &x, &y); double s; s = (y / 100.0) * n; if (s == (int)s) m = (int)s; else m = (int)s + 1; if (m <= x) printf("0\n"); else printf("%d\n", m - x); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int inf = 2000000000; const long long int infLL = 9000000000000000000; const int Mx = 1e3 + 123; long long int n, x, y, k; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; cin >> n >> x >> y; k = (long long int)ceil((n * y) / 100.0); if (k > x) cout << k - x << endl; else cout << 0 << endl; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; scanf("%d%d%d", &n, &x, &y); printf("%d\n", max(0, (n * y / 100 + ((n * y % 100) ? 1 : 0)) - x)); }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; int ans = ceil(n * y * 1.0 / 100); cout << max(ans - x, 0); }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c; scanf("%lld %lld %lld", &a, &b, &c); for (long long i = 0;; i++) { long long val = b + i; long long t = (100 * val) / a; if (t >= c) { cout << i << endl; return 0; } } }
7
CPP
#include <bits/stdc++.h> int main(int argc, const char* argv[]) { int n, x, y; scanf("%d%d%d", &n, &x, &y); int min = ((n * y - 1) / 100 + 1); if (min < x) x = 0; else x = min - x; printf("%d\n", x); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { double a, x, y; cin >> a >> x >> y; double k = ceil(a / 100.0 * y); if (k - x >= 0) cout << k - x; else cout << 0; return 0; }
7
CPP
from math import ceil n,x,y = list(map(int, input().split(" "))) print(ceil(n*y/100)-x if ceil(n*y/100)-x>0 else 0)
7
PYTHON3
import math n,x,y = map(int, input().split()) print(max(math.ceil(n*y/100)-x,0))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { double a, b, c, ans, x, cnt, need; while (cin >> a >> b >> c) { need = c / 100.0; cnt = ceil(a * need); ans = cnt - b; x = 0; cout << max(x, ans) << endl; } return 0; }
7
CPP
import math a,b,c=map(int,input().split()) print(math.ceil((a*c)/100-b) if math.ceil((a*c)/100-b)>0 else 0)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; int ans = (n * y - 1) / 100 + 1 - x; if (ans > 0) cout << ans << endl; else cout << 0 << endl; }
7
CPP
from math import ceil n, x, y = map(int, input().split()) wizard_needed = ceil((n * y) / 100) print(max(0, wizard_needed - x))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long arr[51]; int main() { double n, x, y; cin >> n >> x >> y; ceil(n * y / 100.0) < x ? cout << 0 : cout << ceil(n * y / 100.0) - x; }
7
CPP
#include <bits/stdc++.h> using namespace std; signed main() { double n, m, k; cin >> n >> m >> k; double wiz = (m / n) * 100; if (wiz >= k) cout << 0; else { double cur = ((k - wiz) / 100) * n; cur = ceil(cur); long long ans = cur; cout << ans; } }
7
CPP
#include <bits/stdc++.h> int main() { int n, x, y; while (~scanf("%d%d%d", &n, &x, &y)) { int num = ceil(n * (y * 1.0 / 100)); if (x >= num) printf("0\n"); else printf("%d\n", num - x); } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; double N, W, Y; int main() { double need; int k = 0; cin >> N >> W >> Y; need = N * (Y / 100); if (need <= W) cout << 0; else { if (need != (int)need) k = 1; cout << (int)need - W + k; } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { double P; int N, wizard; scanf("%d %d %lf", &N, &wizard, &P); int jawab = max(0, (int)(ceil(P / 100.0 * (double)N) + 0.005) - wizard); printf("%d\n", jawab); return 0; }
7
CPP
n, x, y = input().split(" ") n = int(n) x = int(x) y = int(y) nx = n - x pp = 0 while ((x + pp)/n) * 100 < y: pp += 1 print(pp)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { long long int n, x, y, need; cin >> n >> x >> y; need = y * n; if ((y * n) % 100 == 0) { need = (y * n) / 100; } else { need = (y * n) / 100; need++; } if (need > x) { cout << need - x << endl; } else { cout << "0" << endl; } return 0; }
7
CPP
import sys my_file = sys.stdin #my_file = open("input.txt", "r") line = [int(i) for i in my_file.readline().split()] n, x, y = line[0], line[1], line[2] res = 0 need = n*y/100 while x < need: x += 1 res += 1 print(res)
7
PYTHON3
#include <bits/stdc++.h> int n, x, y; double dpeople; int ipeople; int main() { scanf("%d %d %d", &n, &x, &y); dpeople = (double)n * y / 100; if (dpeople <= x) { printf("0\n"); return 0; } ipeople = dpeople; if (ipeople == dpeople) printf("%d\n", ipeople - x); else printf("%d\n", ipeople + 1 - x); return 0; }
7
CPP
import sys my_file = sys.stdin #my_file = open("input.txt", "r") line = [int(i) for i in my_file.readline().split()] n, x, y = line[0], line[1], line[2] res = 0 while x < n*y/100: x += 1 res += 1 print(res)
7
PYTHON3
import math x = input().split(" ") y = math.ceil(((int(x[2])*int(x[0]))/100)-int(x[1])) if y > 0: print(y) else: print(0)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k, y; cin >> n >> k >> y; long double tmp = ceil(n * (y / 100.00)); if ((int)tmp - k <= 0) cout << 0; else cout << (int)tmp - k; }
7
CPP
#include <bits/stdc++.h> using namespace std; int n, x, y; int main() { while (cin >> n >> x >> y) { int nd = (n * y + 99) / 100; if (nd <= x) puts("0"); else cout << nd - x << endl; } }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; int min; min = ceil(y * 0.01 * n); if (min > x) cout << (min - x); else cout << 0; }
7
CPP
import math n,x,y = map(int , input().split()) y = y/100 z = math.ceil(n*y) - x print(max(0,z))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { double n, x, y; cin >> n >> x >> y; double res = y / ((float)100.0) * n; if (res <= x) cout << 0; else cout << ceil(res - x); return 0; }
7
CPP
from math import ceil n,x,y=map(int,input().split()) ans=max(0,ceil(y*n/100.0-x)) print(ans)
7
PYTHON3
a, b, c = map(int, input().split()) temp = a * (c / 100) if temp - int(temp) > 0.0: temp = int(temp + 1) else: temp = int(temp) print(max(0, temp - b))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int x, y, z; cin >> x >> y >> z; double a = ceil(((double)z / 100.0) * (double)x); int t = a - y; if (t >= 0) { cout << t << "\n"; } else { cout << 0 << "\n"; } }
7
CPP
n,x,y=map(int,input().split()) if (n*y)/100>(n*y)//100: reqad=((n*y)//100)+1 else: reqad=((n*y)//100) ans=reqad-x if ans<0: print(0) else: print(ans)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; int m = y * n; if (m % 100 > 0) m = (m / 100) + 1; else m = m / 100; int left = m - x; if (left < 0) cout << 0; else cout << left; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; if (y < 100) { float tmp = (float(y) / 100) * n; tmp = ceil(tmp); if (tmp > x) { cout << tmp - x; } else { cout << 0; } } else { float y2 = (float(y) / 100) * 1; float tmp = y2 * n; tmp = ceil(tmp); cout << tmp - x; } return 0; }
7
CPP
import math n,x,y=map(int,input().split()) xx=max(0,math.ceil(n*y/100)-x) print(xx)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { double tota, wizard, percent; cin >> tota >> wizard >> percent; double amount = tota * (percent / 100.0); amount = ceil(amount); if (amount <= wizard) cout << 0 << endl; else { int ans = amount - wizard; cout << ans << endl; } return 0; }
7
CPP
import math from bisect import bisect_left,bisect,bisect_right from itertools import accumulate def index(a, x): 'Locate the leftmost value exactly equal to x' i = bisect_left(a, x) if i != len(a) and a[i] == x: return i raise ValueError def find_lt(a, x): 'Find rightmost value less than x' i = bisect_left(a, x) if i: return a[i-1] raise ValueError def find_le(a, x): 'Find rightmost value less than or equal to x' i = bisect_right(a, x) if i: return a[i-1] raise ValueError def find_gt(a, x): 'Find leftmost value greater than x' i = bisect_right(a, x) if i != len(a): return a[i] raise ValueError def find_ge(a, x): 'Find leftmost item greater than or equal to x' i = bisect_left(a, x) if i != len(a): return a[i] raise ValueError st='' def func(n,x,y): return max(0,math.ceil(y*n/100)-x) for _ in range(1):#int(input())): n,a,b=map(int,input().split()) #n = int(input()) #inp=input().split() #s=input() #l1=[] #l1=list(map(int,input().split())) #l1=list(accumulate(list(map(int,input().split())))) #q=int(input()) #l2 = list(map(int, input().split())) #l1=input().split() #l2=input().split() #func(n,m) st+=str(int(func(n,a,b)))+'\n' print(st)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; int q = (y * n - ((y * n) % 100)) / 100; q += (y * n % 100) != 0; if (q <= x) { cout << "0"; } else cout << q - x; return 0; }
7
CPP
#include <bits/stdc++.h> int main() { int n, x, y, i, j, k = 0, p; scanf("%d%d%d", &n, &x, &y); i = y * n; j = i % 100; k = i / 100; if (j != 0) { k++; } p = k - x; if (p < 0) { printf("0\n"); } else { printf("%d\n", p); } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int main() { ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n, x, y; double demo; cin >> n >> x >> y; demo = ceil(y * n / 100.0); if (x <= demo) cout << demo - x; else cout << 0; return 0; }
7
CPP
from math import * n, x, y = input().split() z = ceil((int(y)/100)*int(n)) if(z > int(x)): s = (z - int(x)) else : s = 0 print(s)
7
PYTHON3
l=input() l=l.split() n=int(l[0]) x=int(l[1]) y=int(l[2]) s=0 while (x/n)*100<y: s+=1 x+=1 print(s)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int run() { int i, p, j; int n, x, y; scanf("%d %d %d", &n, &x, &y); p = y * n / 100; if ((y * n) % 100 != 0) p++; if (p > x) printf("%d\n", p - x); else puts("0"); return 0; } int main() { run(); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int n, x, y; int main() { scanf("%d%d%d", &n, &x, &y); double px = x * 1.0 / n; double py = y * 1.0 / 100; int add = 0; while (px < py) { add++; px = (x + add) * 1.0 / n; } printf("%d\n", add); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; void c_p_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } bool prime(long long c) { for (long long i = 2; i * i <= c; i++) { if (c % i == 0) return 0; } return 1; } vector<long long> sievePrime(long long *p, long long n) { p[0] = p[1] = 0; p[2] = 1; for (long long i = 3; i <= n; i += 2) p[i] = 1; for (long long i = 3; i <= n; i += 2) { if (p[i]) { for (long long j = i * i; j <= n; j += 2) { p[j] = 0; } } } vector<long long> prime; prime.push_back(2); for (long long i = 3; i <= n; i += 2) if (p[i]) prime.push_back(i); return prime; } long long gcd(long long a, long long b) { if (b == 0) return a; else return (gcd(b, a % b)); } int32_t main() { c_p_c(); double n, x, y; cin >> n >> x >> y; long long k = ceil((y / 100) * n); if (k <= x) cout << 0; else cout << k - x; }
7
CPP
import math if __name__ == '__main__': n, x, y = str(input()).split() n = int(n) x = int(x) y = int(y) print(max(0, int(math.ceil(n * y / 100)) - x))
7
PYTHON3
n,x,y=map(int,input().split()) if n*y%100==0 and int(n*y/100)<=x: print(0) elif n*y%100!=0 and int(n*y/100)+1<=x: print(0) else: if n*y%100==0: print(int(n*y/100)-x) else: print(int(n*y/100)+1-x)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int b, x; double a, c; cin >> a >> b >> c; x = ceil(a * (c / 100)); cout << max(0, x - b) << endl; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y, clone = 0; cin >> n >> x >> y; while (double((100 * (x + clone)) / n) < y) clone++; cout << clone; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; int p = y * n - 100 * x; if (p <= 0) cout << 0 << endl; else if (p % 100) cout << p / 100 + 1 << endl; else cout << p / 100 << endl; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; double a, b, c, d; int total; int main() { cin >> a >> b >> c; d = a * c / 100; d = ceil(d); d -= b; if (d < 0) cout << 0; else cout << d; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { int n, x, y; cin >> n >> x >> y; double d = (double(n) * double(y)) / 100.00; int k = ceil(d); if (x >= k) cout << 0; else cout << k - x; return EXIT_SUCCESS; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { double n, y, x; cin >> n >> x >> y; double k = n * y / 100; k = ceil(k); if (k > x) cout << k - x; else cout << 0; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main(int argc, const char* argv[]) { int n, x, y; cin >> n >> x >> y; if (x * 100 >= y * n) { cout << 0; } else { cout << (y * n - x * 100 + 99) / 100; } return 0; }
7
CPP
# cook your dish here inpu = input().split() n = int(inpu[0]) x = int(inpu[1]) y = int(inpu[2]) req = y*n/100.0 if (req != int(req)): req = int(req) + 1 else: req = int(req) if (req <= x): print (0) else: print (req-x)
7
PYTHON3