Submission #6492684


Source Code Expand

Copy
/*{{{*/
#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 push_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(LL &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 LL &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("# ");printf(__VA_ARGS__);puts("");}
#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 = 3e6+10;
LL fac[SIZE],inv[SIZE];
LL mypow(LL x,LL y){
    LL res=1;
    while(y){
        if(y&1)res=res*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return res;
}
LL C(int x,int y){
    if(y<0||y>x)return 0;
    return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
void build(){
    assert(MOD>=SIZE);
    fac[0]=1;
    REPP(i,1,SIZE)fac[i]=fac[i-1]*i%MOD;
    inv[SIZE-1]=mypow(fac[SIZE-1],MOD-2);
    for(int i=SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%MOD;
}
LL N,M;
int main(){
    MOD = 998244353;
    build();
    R(N,M);
    LL an=C(N+3*M-1,N-1);
    ADD(an,-C(N+(3*M-2*M-1)-1,N-1)*N);
    FOR(i,0,M-1){
        int one=3*M-2*i;
        if(one>N)continue;
        ADD(an,-C(N,one)*C(N-1+i,N-1));
    }
    W(an);
    return 0;
}

Submission Info

Submission Time
Task C - GP 2
User dreamoon
Language C++14 (GCC 5.4.1)
Score 900
Code Size 3261 Byte
Status
Exec Time 121 ms
Memory 47232 KB

Compile Error

./Main.cpp: In function ‘void _R(int&)’:
./Main.cpp:45:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void _R(int &x) { scanf("%d", &x); }
                                  ^
./Main.cpp: In function ‘void _R(LL&)’:
./Main.cpp:46:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void _R(LL &x) { scanf("%lld", &x); }
                                   ^
./Main.cpp: In function ‘void _R(double&)’:
./Main.cpp:47:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void _R(double &x) { scanf("%lf", &x); }
                                      ^
./Main.cpp: In function ‘void _R(char&)’:
./Main.cpp:48:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void _R(char &x) { scanf(" %c", &x); }
     ...

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
All 900 / 900 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
Case Name Status Exec Time Memory
01-01.txt 104 ms 47104 KB
01-02.txt 110 ms 47104 KB
01-03.txt 105 ms 47104 KB
01-04.txt 107 ms 47104 KB
01-05.txt 110 ms 47104 KB
01-06.txt 106 ms 47104 KB
01-07.txt 104 ms 47104 KB
01-08.txt 104 ms 47104 KB
01-09.txt 104 ms 47104 KB
01-10.txt 121 ms 47104 KB
01-11.txt 109 ms 47104 KB
01-12.txt 114 ms 47104 KB
01-13.txt 112 ms 47104 KB
01-14.txt 119 ms 47104 KB
01-15.txt 113 ms 47104 KB
01-16.txt 120 ms 47104 KB
01-17.txt 104 ms 47104 KB
01-18.txt 104 ms 47104 KB
01-19.txt 104 ms 47232 KB
01-20.txt 104 ms 47104 KB
01-21.txt 104 ms 47104 KB
01-22.txt 104 ms 47104 KB
sample-01.txt 104 ms 47104 KB
sample-02.txt 104 ms 47104 KB
sample-03.txt 104 ms 47104 KB
sample-04.txt 105 ms 47104 KB