Submission #1603225
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(int I = (A); I < (B); ++I) #define CLR(mat) memset(mat, 0, sizeof(mat)) typedef long long ll; const ll MOD = 1777777777; int N, K; // bの逆元求める ll IE(ll b) { ll ret = 1; FOR(i,0,31) { if(((MOD - 2) >> i) & 1) { ret *= b; ret %= MOD; } b *= b; b %= MOD; } return ret; } // 組み合わせO(r) ll C(ll n, ll r) { r = min(r, n - r); if(r == 1) { return n; } if(r == 0) { return 1; } ll ret = 1; for (ll i = n; i >= n - r + 1; i--) { ret *= i; ret %= MOD; } FOR(i,1,r+1) { ret *= IE(i); ret %= MOD; } 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]); 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 | 1227 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | small | large | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 40 / 40 | 0 / 60 | ||||||
Status |
|
|
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 | 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 |