General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
59246266 Practice:
snow39
1204E - 42 GNU C++14 Accepted 109 ms 31952 KB 2019-08-22 03:06:41 2019-08-22 03:06:41
 
 
→ Source
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=998244853;

int N,M;
ll dp[2020][2020];

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin>>N>>M;

  for(int i=0;i<=max(M,N);i++) dp[0][i]=1;

  for(int i=1;i<=max(N,M);i++){
    for(int j=i;j<=max(M,N);j++){
      add(dp[i][j],dp[i-1][j]);
      add(dp[i][j],dp[i][j-1]);
    }
  }

  ll ans=0;
  for(int i=1;i<=N;i++){
    for(int j=0;j<=min(i-1,M);j++){
      ll res=dp[j][i-1]*dp[N-i][M-j]%MOD;
      res=res*(i-j)%MOD;
      add(ans,res);
    }
  }

  cout<<ans<<endl;

  return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details