Submission #2611599
Source Code Expand
#include<bits/stdc++.h> using namespace std; #define MOD 998244353 long long n,a,b,k; long long fakt[300005], inv[300005]; long long komb(int a,int b){ long long ret; //if(b > a) return 0; ret = fakt[a]; ret = (ret * inv[b]) % MOD; ret = (ret * inv[a - b]) % MOD; return ret; } long long pang(long long a,int b){ if(b == 0) return 1; long long now = pang(a, b / 2); now = (now * now) % MOD; if(b % 2 == 1) now = (now * a) % MOD; return now; } int main(){ cin >> n >> a >> b >> k; fakt[0] = 1; inv[0] = 1; fakt[1] = 1; inv[1] = 1; for(int i = 2; i <= 300000; i++){ fakt[i] = (fakt[i - 1] * i) % MOD; inv[i] = pang(fakt[i], MOD - 2); } long long jaw = 0; for(long long i = 0; i <= 300000; i++){ if(i > n) break; long long sisa = k - a * i; if(sisa % b != 0 || sisa < 0) continue; long long pake = sisa / b; if(pake > n) continue; long long tamb = (komb(n, i) * komb(n, pake)) % MOD; // cout << i << " " << tamb << " here\n"; jaw = (jaw + tamb) % MOD; } cout << jaw << "\n"; }
Submission Info
Submission Time | |
---|---|
Task | B - RGB Coloring |
User | AlphaQQ |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1077 Byte |
Status | AC |
Exec Time | 90 ms |
Memory | 4992 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample01.txt, sample02.txt, sample03.txt |
All | sample01.txt, sample02.txt, sample03.txt, in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, in21.txt, sample01.txt, sample02.txt, sample03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in01.txt | AC | 88 ms | 4992 KB |
in02.txt | AC | 88 ms | 4992 KB |
in03.txt | AC | 88 ms | 4992 KB |
in04.txt | AC | 88 ms | 4992 KB |
in05.txt | AC | 88 ms | 4992 KB |
in06.txt | AC | 88 ms | 4992 KB |
in07.txt | AC | 88 ms | 4992 KB |
in08.txt | AC | 86 ms | 4992 KB |
in09.txt | AC | 88 ms | 4992 KB |
in10.txt | AC | 87 ms | 4992 KB |
in11.txt | AC | 87 ms | 4992 KB |
in12.txt | AC | 86 ms | 4992 KB |
in13.txt | AC | 87 ms | 4992 KB |
in14.txt | AC | 85 ms | 4992 KB |
in15.txt | AC | 86 ms | 4992 KB |
in16.txt | AC | 85 ms | 4992 KB |
in17.txt | AC | 87 ms | 4992 KB |
in18.txt | AC | 89 ms | 4992 KB |
in19.txt | AC | 90 ms | 4992 KB |
in20.txt | AC | 90 ms | 4992 KB |
in21.txt | AC | 84 ms | 4992 KB |
sample01.txt | AC | 85 ms | 4992 KB |
sample02.txt | AC | 85 ms | 4992 KB |
sample03.txt | AC | 86 ms | 4992 KB |