Submission #8475265


Source Code Expand

Copy
#include <cstdio>

using namespace std;

const int mod = 1'000'000'007;

int mul(int a, int b) {
  return (int)((long long)a * b % mod);
}

int pw(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return res;
}

int inv(int a) {
  return pw(a, mod - 2);
}

const int N = 1'000'009;

int f[N];
int rf[N];

int choose(int n, int k) {
  return mul(f[n], mul(rf[k], rf[n - k]));
}

int main() {
  f[0] = 1;
  rf[0] = 1;
  for (int i = 1; i < N; ++i) {
    f[i] = mul(f[i - 1], i);
    rf[i] = inv(f[i]);
  }
  int x, y;
  scanf("%d%d", &x, &y);
  int i = 1;
  while (i <= x && i <= y) {
    if ((x - i) + (y - i) == i) {
      break;
    }
    ++i;
  }
  printf("%d\n", i > x || i > y ? 0 : choose(i, x - i));
}

Submission Info

Submission Time
Task D - Knight
User fragusbot
Language C++14 (GCC 5.4.1)
Score 400
Code Size 850 Byte
Status AC
Exec Time 160 ms
Memory 7936 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:44: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 160 ms 7936 KB
hand_02 AC 159 ms 7936 KB
hand_03 AC 159 ms 7936 KB
hand_04 AC 159 ms 7936 KB
random_01 AC 159 ms 7936 KB
random_02 AC 159 ms 7936 KB
random_03 AC 159 ms 7936 KB
random_04 AC 159 ms 7936 KB
random_05 AC 159 ms 7936 KB
random_06 AC 159 ms 7936 KB
random_07 AC 159 ms 7936 KB
random_08 AC 159 ms 7936 KB
random_09 AC 159 ms 7936 KB
random_10 AC 159 ms 7936 KB
random_11 AC 159 ms 7936 KB
random_12 AC 159 ms 7936 KB
random_13 AC 159 ms 7936 KB
random_14 AC 159 ms 7936 KB
random_15 AC 159 ms 7936 KB
random_16 AC 159 ms 7936 KB
random_17 AC 159 ms 7936 KB
random_18 AC 159 ms 7936 KB
random_19 AC 160 ms 7936 KB
random_20 AC 159 ms 7936 KB
random_21 AC 159 ms 7936 KB
random_22 AC 159 ms 7936 KB
random_23 AC 160 ms 7936 KB
random_24 AC 159 ms 7936 KB
sample_01 AC 159 ms 7936 KB
sample_02 AC 159 ms 7936 KB
sample_03 AC 159 ms 7936 KB