Submission #1781024
Source Code Expand
#include<bits/stdc++.h> using namespace std; typedef long long int64; const int mod = 1777777777; inline int64 modPow(int64 x, int64 n) { if(n == 0) return (1); int64 ret = modPow(x, n / 2); (ret *= ret) %= mod; if(n & 1) (ret *= x) %= mod; return (ret); } inline int64 modInv(int64 a) { return (modPow(a, mod - 2)); } inline int64 modCombination(int64 n, int k) { int64 res = 1; for(unsigned long long i = 1; i <= k; ++i) { (res *= n-- % mod) %= mod; (res *= modInv(i)) %= mod; } return res; } int main() { int64 N; int K; cin >> N >> K; int64 mult = 1; for(int i = 1; i <= K; i++) { (mult *= i) %= mod; } int64 ret = 0; for(int i = 2; i <= K; i++) { (mult *= modInv(i)) %= mod; if(i & 1) (ret += mod - mult) %= mod; else (ret += mult) %= mod; } cout << modCombination(N, K) * ret % mod << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - 高橋君、24歳 |
User | ei13333 |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 919 Byte |
Status | AC |
Exec Time | 224 ms |
Memory | 256 KB |
Judge Result
Set Name | small | large | ||||
---|---|---|---|---|---|---|
Score / Max Score | 40 / 40 | 60 / 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 | AC | 87 ms | 256 KB |
01_large/large_01_rand_02.txt | AC | 171 ms | 256 KB |
01_large/large_01_rand_03.txt | AC | 65 ms | 256 KB |
01_large/large_01_rand_05.txt | AC | 219 ms | 256 KB |
01_large/large_01_rand_07.txt | AC | 5 ms | 256 KB |
01_large/large_01_rand_08.txt | AC | 22 ms | 256 KB |
01_large/large_01_rand_09.txt | AC | 131 ms | 256 KB |
01_large/large_01_rand_10.txt | AC | 30 ms | 256 KB |
01_large/large_01_rand_13.txt | AC | 224 ms | 256 KB |
01_large/large_01_rand_14.txt | AC | 106 ms | 256 KB |
01_large/large_01_rand_18.txt | AC | 198 ms | 256 KB |