Submission #2612732


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

ll n,a,b,k;

ll fact[300010];
const ll mod = 998244353;

ll Pow(ll b, ll e){
	if(e<0) e=(-e)*(mod-2)%(mod-1);
	ll ret=1;
	while(e){
		if(e&1) (ret*=b)%=mod;
		(b*=b)%=mod; e>>=1;
	}
	return ret;
}

ll Comb(ll n, ll r){
	return fact[n]*Pow(fact[r], -1)%mod*Pow(fact[n-r], -1)%mod;
}

int main()
{
	read(n,a,b,k);
	fact[0]=1;
	for(int i=1; i<=n; ++i) fact[i]=fact[i-1]*i%mod;
	ll ans = 0;
	for(int p=0; p<=n; ++p){
		ll q = (k-p*a)/b;
		if(p*a + q*b == k && 0<=q && q<=n){
			(ans += Comb(n, p) * Comb(n, q) % mod) %= mod;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Submission Info

Submission Time
Task B - RGB Coloring
User Namnamseo
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1013 Byte
Status AC
Exec Time 157 ms
Memory 2560 KiB

Compile Error

./Main.cpp: In function ‘void read(int&)’:
./Main.cpp:6:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void read(int& x){ scanf("%d",&x); }
                                  ^
./Main.cpp: In function ‘void read(ll&)’:
./Main.cpp:7:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void read(ll& x){ scanf("%lld",&x); }
                                   ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 27
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 7 ms 2560 KiB
in02.txt AC 7 ms 2560 KiB
in03.txt AC 7 ms 2560 KiB
in04.txt AC 7 ms 2560 KiB
in05.txt AC 7 ms 2560 KiB
in06.txt AC 7 ms 2560 KiB
in07.txt AC 7 ms 2560 KiB
in08.txt AC 3 ms 896 KiB
in09.txt AC 6 ms 2560 KiB
in10.txt AC 5 ms 2048 KiB
in11.txt AC 6 ms 2176 KiB
in12.txt AC 3 ms 1024 KiB
in13.txt AC 29 ms 1664 KiB
in14.txt AC 7 ms 640 KiB
in15.txt AC 7 ms 1024 KiB
in16.txt AC 4 ms 512 KiB
in17.txt AC 31 ms 1792 KiB
in18.txt AC 64 ms 2560 KiB
in19.txt AC 157 ms 2560 KiB
in20.txt AC 143 ms 2560 KiB
in21.txt AC 1 ms 256 KiB
sample01.txt AC 1 ms 256 KiB
sample02.txt AC 1 ms 256 KiB
sample03.txt AC 3 ms 896 KiB