Submission #8474302


Source Code Expand

Copy
#include <bits/stdc++.h>

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

const int MOD = 1e9+7;

int fat[1000006];

int exp(int a, int b) {
	int r = 1;

	while(b) {
		if(b&1) r = ((ll)r*a)%MOD;
		b/=2;
		a = ((ll)a*a)%MOD;
	}

	return r;
}

int main() {
	int x,y;

	fat[0] = 1;
	for(int i = 1; i <= 1000000; i++)
		fat[i] = ((ll)fat[i-1]*i)%MOD;

	scanf("%d %d", &x, &y);

	if((x+y)%3 != 0) {
		printf("0\n");
		return 0;
	}

	int cntA = 0, cntB = 0;
	while(x > 0 && y > 0) {
		if(x > y) {cntA++; x -= 2; y--;}
		else {cntB++; x--; y-=2;}
	}

	if(x != 0 or y != 0) {
		printf("0\n");
		return 0;
	}

	int ans = ((ll)fat[cntA+cntB]*exp(fat[cntA], MOD-2))%MOD;
	ans = ((ll)ans*exp(fat[cntB], MOD-2))%MOD;
	printf("%d\n", ans);

    return 0;
}

Submission Info

Submission Time
Task D - Knight
User pedrohlf
Language C++14 (GCC 5.4.1)
Score 400
Code Size 852 Byte
Status AC
Exec Time 8 ms
Memory 4096 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:34:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &x, &y);
                        ^

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 8 ms 4096 KB
hand_02 AC 8 ms 4096 KB
hand_03 AC 8 ms 4096 KB
hand_04 AC 8 ms 4096 KB
random_01 AC 8 ms 4096 KB
random_02 AC 8 ms 4096 KB
random_03 AC 8 ms 4096 KB
random_04 AC 8 ms 4096 KB
random_05 AC 8 ms 4096 KB
random_06 AC 8 ms 4096 KB
random_07 AC 8 ms 4096 KB
random_08 AC 8 ms 4096 KB
random_09 AC 8 ms 4096 KB
random_10 AC 8 ms 4096 KB
random_11 AC 8 ms 4096 KB
random_12 AC 8 ms 4096 KB
random_13 AC 8 ms 4096 KB
random_14 AC 8 ms 4096 KB
random_15 AC 8 ms 4096 KB
random_16 AC 8 ms 4096 KB
random_17 AC 8 ms 4096 KB
random_18 AC 8 ms 4096 KB
random_19 AC 8 ms 4096 KB
random_20 AC 8 ms 4096 KB
random_21 AC 8 ms 4096 KB
random_22 AC 8 ms 4096 KB
random_23 AC 8 ms 4096 KB
random_24 AC 8 ms 4096 KB
sample_01 AC 8 ms 4096 KB
sample_02 AC 8 ms 4096 KB
sample_03 AC 8 ms 4096 KB