Submission #1725730
Source Code Expand
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define fi first #define se second #define mp make_pair #define pb push_back #define fbo find_by_order #define ook order_of_key typedef long long ll; typedef pair<int,int> ii; typedef vector<int> vi; typedef long double ld; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; typedef set<int>::iterator sit; typedef map<int,int>::iterator mit; typedef vector<int>::iterator vit; const int MOD = 1e9 + 7; void add(int &a, int b) { a+=b; while(a>=MOD) a-=MOD; } int mult(int a, int b) { return (a*1LL*b)%MOD; } int dp[4017][2017][2]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,m,kk; cin>>n>>m>>kk; dp[0][0][0] = 1; for(int i = 0; i < (n+m-1)/(kk-1); i++) { for(int j = 0; j <= n; j++) { for(int k = 0; k < 2; k++) { int v = dp[i][j][k]; if(v==0) continue; for(int z=0;z<kk;z++) { int newk=(z!=0); int newi=i+1; int newj=j+z; if(newj>n) continue; add(dp[newi][newj][newk],v); } } } } int ans=0; for(int i=1;i<=(n+m-1)/(kk-1);i++) { for(int j = n; j >= 0; j-=(kk-1)) { int sj = (kk-1)*i - j; if(sj>=0&&sj<=m-1&&(m-1-sj)%(kk-1)==0) { add(ans,dp[i][j][1]); } } } cout<<ans<<'\n'; }
Submission Info
Submission Time | |
---|---|
Task | E - Eternal Average |
User | vjudge4 |
Language | C++14 (GCC 5.4.1) |
Score | 1600 |
Code Size | 1395 Byte |
Status | AC |
Exec Time | 121 ms |
Memory | 61824 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1600 / 1600 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 1 ms | 256 KB |
02.txt | AC | 121 ms | 61824 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 80 ms | 31616 KB |
06.txt | AC | 4 ms | 11008 KB |
07.txt | AC | 22 ms | 7168 KB |
08.txt | AC | 2 ms | 640 KB |
09.txt | AC | 59 ms | 4096 KB |
10.txt | AC | 55 ms | 1536 KB |
11.txt | AC | 9 ms | 256 KB |
12.txt | AC | 5 ms | 256 KB |
13.txt | AC | 42 ms | 768 KB |
14.txt | AC | 19 ms | 384 KB |
15.txt | AC | 38 ms | 768 KB |
16.txt | AC | 1 ms | 256 KB |
17.txt | AC | 14 ms | 384 KB |
18.txt | AC | 11 ms | 896 KB |
19.txt | AC | 42 ms | 33664 KB |
20.txt | AC | 54 ms | 9344 KB |
21.txt | AC | 1 ms | 256 KB |
22.txt | AC | 70 ms | 7424 KB |
23.txt | AC | 43 ms | 1152 KB |
24.txt | AC | 38 ms | 1024 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 2 ms | 384 KB |