Submission #1083816


Source Code Expand

#include <bits/stdc++.h>
#define f(a, n) for (int a=0; a<n; a++)
#define F(a, n) for (int a=1; a<=n; a++)
#define ll long long
using namespace std;
const ll MOD = 1000000007;
unordered_map<ll, ll> gmp;
ll pairit(ll a, ll b){
	return (a<<32) + b;	
}
ll g(ll a, ll b){
	if (a==0) return 0;
	if (a==1) return 1;
	ll tmp=pairit(a,b);
	if (gmp.count(tmp)) return gmp[tmp];	
	if (b==0) gmp[tmp] = (g(a-1, 0) + g(a-1, 1) ) %MOD;
	else gmp[tmp] = (g(a, b-1) + g(a-1, b+1)) % MOD;
	return gmp[tmp];
}
ll powa(ll a, ll b){
	if (b<=0) return 1;
	else if (b%2) return (powa((a*a)%MOD,b/2) * a) % MOD;
	return powa((a*a)%MOD,b/2);
}
ll N, K;
int main(){
	ios::sync_with_stdio(false);
	cin>>N>>K;
	cout<<( (g(K, N-K) - g(K-1, N-K+1) + MOD)* powa(2, N-K-1) ) % MOD << endl; 
	return 0;
}

Submission Info

Submission Time
Task F - Solitaire
User meeeep
Language C++14 (GCC 5.4.1)
Score 1200
Code Size 804 Byte
Status AC
Exec Time 441 ms
Memory 79568 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1200 / 1200
Status
AC × 3
AC × 26
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 3 ms 256 KB
00_example_02.txt AC 3 ms 256 KB
00_example_03.txt AC 346 ms 63952 KB
01.txt AC 3 ms 256 KB
02.txt AC 129 ms 28916 KB
03.txt AC 3 ms 256 KB
04.txt AC 5 ms 768 KB
05.txt AC 3 ms 256 KB
06.txt AC 3 ms 256 KB
07.txt AC 3 ms 256 KB
08.txt AC 3 ms 256 KB
09.txt AC 400 ms 72656 KB
10.txt AC 3 ms 256 KB
11.txt AC 3 ms 256 KB
12.txt AC 393 ms 71120 KB
13.txt AC 4 ms 512 KB
14.txt AC 271 ms 58384 KB
15.txt AC 33 ms 7204 KB
16.txt AC 277 ms 58384 KB
17.txt AC 198 ms 38032 KB
18.txt AC 383 ms 70096 KB
19.txt AC 361 ms 66128 KB
20.txt AC 176 ms 34192 KB
21.txt AC 3 ms 256 KB
22.txt AC 441 ms 79568 KB
23.txt AC 3 ms 256 KB