Submission #2607571
Source Code Expand
#include <bits/stdc++.h> #define itn int #define all(x) (x).begin(), (x).end() #define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin()) using namespace std; inline int nxt() { int x; scanf("%d", &x); return x; } const int mod = 998244353; const int N = 333333; long long fact[N]; long long inv[N]; long long invfact[N]; long long C(int n, int k) { return fact[n] * invfact[k] % mod * invfact[n - k] % mod; } int main() { fact[0] = invfact[0] = 1; for (int i = 1; i < N; ++i) { inv[i] = (i == 1) ? 1 : mod - mod / i * inv[mod % i] % mod; fact[i] = fact[i - 1] * i % mod; invfact[i] = invfact[i - 1] * inv[i] % mod; assert(inv[i] * i % mod == 1); } int n = nxt(), a = nxt(), b = nxt(); long long k; cin >> k; long long ans = 0; for (int i = 0; i <= n; ++i) { long long l = 1ll * i * a; if (k < l) { break; } long long kk = k - l; if (kk % b) { continue; } long long lb = kk / b; if (lb > n) { continue; } ans += 1ll * C(n, i) * C(n, lb) % mod; } cout << ans % mod << "\n"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - RGB Coloring |
User | Golovanov399 |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1124 Byte |
Status | AC |
Exec Time | 14 ms |
Memory | 8064 KB |
Compile Error
./Main.cpp: In function ‘int nxt()’: ./Main.cpp:11:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &x); ^
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 | 11 ms | 8064 KB |
in02.txt | AC | 12 ms | 8064 KB |
in03.txt | AC | 10 ms | 8064 KB |
in04.txt | AC | 12 ms | 8064 KB |
in05.txt | AC | 12 ms | 8064 KB |
in06.txt | AC | 10 ms | 8064 KB |
in07.txt | AC | 12 ms | 8064 KB |
in08.txt | AC | 9 ms | 8064 KB |
in09.txt | AC | 12 ms | 8064 KB |
in10.txt | AC | 11 ms | 8064 KB |
in11.txt | AC | 10 ms | 8064 KB |
in12.txt | AC | 9 ms | 8064 KB |
in13.txt | AC | 10 ms | 8064 KB |
in14.txt | AC | 9 ms | 8064 KB |
in15.txt | AC | 9 ms | 8064 KB |
in16.txt | AC | 9 ms | 8064 KB |
in17.txt | AC | 12 ms | 8064 KB |
in18.txt | AC | 13 ms | 8064 KB |
in19.txt | AC | 14 ms | 8064 KB |
in20.txt | AC | 14 ms | 8064 KB |
in21.txt | AC | 8 ms | 8064 KB |
sample01.txt | AC | 9 ms | 8064 KB |
sample02.txt | AC | 9 ms | 8064 KB |
sample03.txt | AC | 9 ms | 8064 KB |