Submission #1084165
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define int ll
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;
template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
os<<"("<<p.first<<","<<p.second<<")";
return os;
}
template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
os<<"[";
REP(i,(int)v.size()){
if(i)os<<",";
os<<v[i];
}
os<<"]";
return os;
}
int read(){
int i;
scanf("%lld",&i);
return i;
}
void printSpace(){
printf(" ");
}
void printEoln(){
printf("\n");
}
void print(int x,int suc=1){
printf("%lld",x);
if(suc==1)
printEoln();
if(suc==2)
printSpace();
}
string readString(){
static char buf[3341919];
scanf("%s",buf);
return string(buf);
}
char* readCharArray(){
static char buf[3341919];
static int bufUsed=0;
char* ret=buf+bufUsed;
scanf("%s",ret);
bufUsed+=strlen(ret)+1;
return ret;
}
template<class T,class U>
void chmax(T& a,U b){
if(a<b)
a=b;
}
template<class T,class U>
void chmin(T& a,U b){
if(a>b)
a=b;
}
template<class T>
T Sq(const T& t){
return t*t;
}
const int inf=LLONG_MAX/3;
const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
a=((ll)a+b)%mod;
}
template<class T,class U>
void sub(T& a,U b){
a=((ll)a-b%mod+mod)%mod;
}
template<class T,class U>
void mult(T& a,U b){
a=((ll)a*b)%mod;
}
ll modPow(ll a,ll p){
ll s=1;
REP(i,30){
if((p>>i)&1)
mult(s,a);
mult(a,a);
}
return s;
}
ll modInv(ll a){
return modPow(a,mod-2);
}
const int Nmax=2017;
int dp[Nmax][Nmax];
signed main(){
vi fact{1};
FOR(i,1,114514)
fact.PB(fact.back()*i%mod);
vi factInv;
for(auto v:fact)
factInv.PB(modInv(v));
const auto comb=[&](int a,int b){
return fact[a]*factInv[b]%mod*factInv[a-b]%mod;
};
int n=read(),k=read();
dp[0][0]=1;
FOR(i,1,Nmax){
int sum=dp[i-1][i-1];
FOR(j,i,Nmax){
add(sum,dp[i-1][j]);
dp[i][j]=sum;
}
}
int ans=0;
REP(i,n)
add(ans,dp[k-1][i]);
if(n-k>0)
mult(ans,modPow(2,n-k-1));
cout<<ans<<endl;
}
Submission Info
Submission Time
2017-01-28 22:30:38+0900
Task
F - Solitaire
User
maroonrk
Language
C++14 (GCC 5.4.1)
Score
1200
Code Size
2446 Byte
Status
AC
Exec Time
55 ms
Memory
25076 KB
Compile Error
./Main.cpp: In function ‘ll read()’:
./Main.cpp:38:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&i);
^
./Main.cpp: In function ‘std::string readString()’:
./Main.cpp:60:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s",buf);
^
./Main.cpp: In function ‘char* readCharArray()’:
./Main.cpp:68:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s",ret);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
1200 / 1200
Status
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
54 ms
25076 KB
00_example_02.txt
AC
54 ms
25076 KB
00_example_03.txt
AC
54 ms
25076 KB
01.txt
AC
54 ms
25076 KB
02.txt
AC
54 ms
25076 KB
03.txt
AC
54 ms
25076 KB
04.txt
AC
54 ms
25076 KB
05.txt
AC
54 ms
25076 KB
06.txt
AC
54 ms
25076 KB
07.txt
AC
54 ms
25076 KB
08.txt
AC
54 ms
25076 KB
09.txt
AC
54 ms
25076 KB
10.txt
AC
54 ms
25076 KB
11.txt
AC
54 ms
25076 KB
12.txt
AC
54 ms
25076 KB
13.txt
AC
54 ms
25076 KB
14.txt
AC
54 ms
25076 KB
15.txt
AC
54 ms
25076 KB
16.txt
AC
54 ms
25076 KB
17.txt
AC
54 ms
25076 KB
18.txt
AC
54 ms
25076 KB
19.txt
AC
54 ms
25076 KB
20.txt
AC
54 ms
25076 KB
21.txt
AC
54 ms
25076 KB
22.txt
AC
55 ms
25076 KB
23.txt
AC
54 ms
25076 KB