Submission #8481092


Source Code Expand

Copy
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;
ll int nf[2000001];
ll int inv[2000001];
int main(){
	//ios_base::sync_with_stdio(0); cin.tie(0);
	ll int N=1000000;
	nf[0]=1; nf[1]=1;
	for(ll int i=2;i<=N;i++)
		nf[i]=(nf[i-1]*i)%MOD;
	ll int k=1000000005,invN=1,now=nf[N];
	for(ll int i=0;i<=30;i++){
		if(k&(1<<i)){
			k-=(k&(1<<i));
			invN=(invN*now)%MOD;
		}
		now=(now*now)%MOD;
	}
	inv[N]=invN;
	for(ll int i=N-1;i>=1;i--){
		inv[i]=((i+1)*inv[i+1])%MOD;
	}
	inv[0]=1;
	ll int X,Y,U,R;
	cin>>X>>Y;
	if((X+Y)%3 || 2*Y<X || 2*X<Y){
		cout<<0; return 0;
	}
	U=(2*Y-X)/3; R=(2*X-Y)/3;
	cout<<(((nf[U+R]*inv[U])%MOD)*inv[R])%MOD;
}

Submission Info

Submission Time
Task D - Knight
User Seremo
Language C++14 (GCC 5.4.1)
Score 400
Code Size 706 Byte
Status AC
Exec Time 16 ms
Memory 18688 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 31
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All hand_01, hand_02, hand_03, hand_04, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, random_10, random_11, random_12, random_13, random_14, random_15, random_16, random_17, random_18, random_19, random_20, random_21, random_22, random_23, random_24, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
hand_01 AC 16 ms 18688 KB
hand_02 AC 16 ms 18688 KB
hand_03 AC 16 ms 18688 KB
hand_04 AC 16 ms 18688 KB
random_01 AC 16 ms 18688 KB
random_02 AC 16 ms 18688 KB
random_03 AC 16 ms 18688 KB
random_04 AC 16 ms 18688 KB
random_05 AC 16 ms 18688 KB
random_06 AC 16 ms 18688 KB
random_07 AC 16 ms 18688 KB
random_08 AC 16 ms 18688 KB
random_09 AC 16 ms 18688 KB
random_10 AC 16 ms 18688 KB
random_11 AC 16 ms 18688 KB
random_12 AC 16 ms 18688 KB
random_13 AC 16 ms 18688 KB
random_14 AC 16 ms 18688 KB
random_15 AC 16 ms 18688 KB
random_16 AC 16 ms 18688 KB
random_17 AC 16 ms 18688 KB
random_18 AC 16 ms 18688 KB
random_19 AC 16 ms 18688 KB
random_20 AC 16 ms 18688 KB
random_21 AC 16 ms 18688 KB
random_22 AC 16 ms 18688 KB
random_23 AC 16 ms 18688 KB
random_24 AC 16 ms 18688 KB
sample_01 AC 16 ms 18688 KB
sample_02 AC 16 ms 18688 KB
sample_03 AC 16 ms 18688 KB