Submission #1603245


Source Code Expand

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const ll MOD = 1777777777;
ll N, K;
// bの逆元求める
ll IE(ll b) {
  ll ret = 1;
  ll M = MOD - 2;
  while(M)
  {
    if(M & 1) {
      ret *= b;
      ret %= MOD;
    }
    b *= b;
    b %= MOD;
    M >>= 1;
  }
  return ret % MOD;
}

// 組み合わせO(r)
ll C(ll n, ll r) {
  r = min(r, n - r);
  ll ret = 1;
  ll rr = r;
  for (ll i = n; i >= n - r + 1; i--)
  {
    ret = (ret * i) % MOD;
    ret = (ret * IE(rr)) % MOD;
    rr--;
  }
  return ret;
}

int main()
{
  cin >> N >> K;
  ll ans = C(N, K);
  ll a[K + 1];
  CLR(a);
  a[2] = 1;
  FOR(i,3,K+1) {
    a[i] = (i - 1) * ((a[i - 1] + a[i - 2]) % MOD);
    a[i] %= MOD;
  }
  ans *= a[K];
  ans %= MOD;
  cout << ans << endl;
  return 0;
}

Submission Info

Submission Time
Task C - 高橋君、24歳
User nenuon
Language C++14 (GCC 5.4.1)
Score 40
Code Size 1183 Byte
Status WA
Exec Time 77 ms
Memory 3840 KB

Judge Result

Set Name small large
Score / Max Score 40 / 40 0 / 60
Status
AC × 15
AC × 16
WA × 11
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 AC 1 ms 256 KB
01_large/large_01_rand_01.txt WA 31 ms 1664 KB
01_large/large_01_rand_02.txt WA 60 ms 3072 KB
01_large/large_01_rand_03.txt WA 24 ms 1280 KB
01_large/large_01_rand_05.txt WA 76 ms 3840 KB
01_large/large_01_rand_07.txt WA 3 ms 256 KB
01_large/large_01_rand_08.txt WA 8 ms 640 KB
01_large/large_01_rand_09.txt WA 46 ms 2304 KB
01_large/large_01_rand_10.txt WA 11 ms 768 KB
01_large/large_01_rand_13.txt WA 77 ms 3840 KB
01_large/large_01_rand_14.txt WA 37 ms 1920 KB
01_large/large_01_rand_18.txt WA 69 ms 3456 KB