Submission #1603063


Source Code Expand

#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;

using namespace std;

ll M = 1777777777;

// 場合の数
ll comb(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
        r %= M;
    }
    return r;
}

// 完全順列
ll derangement(int N) {
  if (N <= 1) {
    return 0;
  } else if (N == 2) {
    return 1;
  }
  ll p2 = 0, p1 = 1;
  for (int i = 3; i <= N; i++) {
    ll n = (i - 1) * (p1 + p2);
    n %= M;
    p2 = p1;
    p1 = n;
  }
  return p1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;

    ll c1 = comb(N, K);
    ll c2 = derangement(K);

    cout << c1 % M * c2 % M << endl;
    return 0;
}

Submission Info

Submission Time
Task C - 高橋君、24歳
User sinhrks
Language C++14 (GCC 5.4.1)
Score 40
Code Size 1054 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name small large
Score / Max Score 40 / 40 0 / 60
Status
AC × 15
AC × 15
WA × 12
Set Name Test Cases
small 00_small/small_00_sample1.txt, 00_small/small_00_sample2.txt, 00_small/small_00_sample3.txt, 00_small/small_00_sample4.txt, 00_small/small_01_rand_01.txt, 00_small/small_01_rand_02.txt, 00_small/small_01_rand_03.txt, 00_small/small_01_rand_05.txt, 00_small/small_01_rand_07.txt, 00_small/small_01_rand_08.txt, 00_small/small_01_rand_09.txt, 00_small/small_01_rand_10.txt, 00_small/small_01_rand_13.txt, 00_small/small_01_rand_14.txt, 00_small/small_01_rand_18.txt
large 00_small/small_00_sample1.txt, 00_small/small_00_sample2.txt, 00_small/small_00_sample3.txt, 00_small/small_00_sample4.txt, 00_small/small_01_rand_01.txt, 00_small/small_01_rand_02.txt, 00_small/small_01_rand_03.txt, 00_small/small_01_rand_05.txt, 00_small/small_01_rand_07.txt, 00_small/small_01_rand_08.txt, 00_small/small_01_rand_09.txt, 00_small/small_01_rand_10.txt, 00_small/small_01_rand_13.txt, 00_small/small_01_rand_14.txt, 00_small/small_01_rand_18.txt, 01_large/large_00_sample5.txt, 01_large/large_01_rand_01.txt, 01_large/large_01_rand_02.txt, 01_large/large_01_rand_03.txt, 01_large/large_01_rand_05.txt, 01_large/large_01_rand_07.txt, 01_large/large_01_rand_08.txt, 01_large/large_01_rand_09.txt, 01_large/large_01_rand_10.txt, 01_large/large_01_rand_13.txt, 01_large/large_01_rand_14.txt, 01_large/large_01_rand_18.txt
Case Name Status Exec Time Memory
00_small/small_00_sample1.txt AC 1 ms 256 KB
00_small/small_00_sample2.txt AC 1 ms 256 KB
00_small/small_00_sample3.txt AC 1 ms 256 KB
00_small/small_00_sample4.txt AC 1 ms 256 KB
00_small/small_01_rand_01.txt AC 1 ms 256 KB
00_small/small_01_rand_02.txt AC 1 ms 256 KB
00_small/small_01_rand_03.txt AC 1 ms 256 KB
00_small/small_01_rand_05.txt AC 1 ms 256 KB
00_small/small_01_rand_07.txt AC 1 ms 256 KB
00_small/small_01_rand_08.txt AC 1 ms 256 KB
00_small/small_01_rand_09.txt AC 1 ms 256 KB
00_small/small_01_rand_10.txt AC 1 ms 256 KB
00_small/small_01_rand_13.txt AC 1 ms 256 KB
00_small/small_01_rand_14.txt AC 1 ms 256 KB
00_small/small_01_rand_18.txt AC 1 ms 256 KB
01_large/large_00_sample5.txt WA 1 ms 256 KB
01_large/large_01_rand_01.txt WA 1 ms 256 KB
01_large/large_01_rand_02.txt WA 1 ms 256 KB
01_large/large_01_rand_03.txt WA 1 ms 256 KB
01_large/large_01_rand_05.txt WA 1 ms 256 KB
01_large/large_01_rand_07.txt WA 1 ms 256 KB
01_large/large_01_rand_08.txt WA 1 ms 256 KB
01_large/large_01_rand_09.txt WA 1 ms 256 KB
01_large/large_01_rand_10.txt WA 1 ms 256 KB
01_large/large_01_rand_13.txt WA 1 ms 256 KB
01_large/large_01_rand_14.txt WA 1 ms 256 KB
01_large/large_01_rand_18.txt WA 1 ms 256 KB