Submission #2703013


Source Code Expand

#include <bits/stdc++.h> 

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<n;(i)++)
#define rep1(i,n) for(int (i)=1;(i)<=n;(i)++)
#define repU(i,bottom,ceiling) for(int (i)=(bottom);(i)<=(ceiling);(i)++)
#define repD(i,ceiling,bottom) for(int (i)=(ceiling);(i)>=(bottom);(i)--)
#define pub push_back
#define pob pop_back
#define prf printf
#define scf scanf
#define vci(v) for(int i=0;i<v.size();i++) cin>>v[i]
#define vco(v) for(int i=0;i<v.size();i++){ cout<<v[i]<<' '; } cout<<endl
#define mkp make_pair
#define fir first
#define sec second
#define clr(a) memset((a),0,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vdb;
typedef vector<vector<double>> vvdb;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<pair<int,int>> vpii;
typedef pair<int,int> pii;

const vector<pair<int,int>> Dir={{1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1}};
const int Inf=(int)2e9+1e8;
const int Mod=(int)1e9+7;

template<typename T,typename U>                                                   
inline pair<T,U> operator+(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir+r.fir,l.sec+r.sec};                                    
} 

template<typename T,typename U> 
inline pair<T,U> operator-(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir-r.fir,l.sec-r.sec};                                    
} 

template<typename T,typename U>                                                   
inline pair<T,U> operator*(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir*r.fir,l.sec*r.sec};                                    
}

template<typename T> inline T gcd(T a,T b){ if(a%b){ return gcd(b,a%b); }else{ return b; } }
template<typename T> inline T lcm(T a,T b){ return a/gcd(a,b)*b; }

inline long long Mpow(long long n,long long m,long long mod){
	long long res=1,pow=n;
	while(m){
		if(m&1) res=(res*pow)%mod;
		pow=(pow*pow)%mod;
		m>>=1;
	}
	return res;
}

pair<int,int> Thre;
vector<int> v;

template<typename T> inline bool judge(T n){ return (Thre.first<=v[n]&&Thre.sec>=v[n]); }

template<typename T> inline T BiS(T bottom,T ceiling,bool thretype){
	T upper=ceiling+thretype;
	T lower=bottom-(!thretype);
	while(upper-lower>1){
		T mid=(upper+lower)/2;
		if(judge(mid)) (thretype?lower:upper)=mid;
		else (thretype?upper:lower)=mid;
	}
	return (thretype?lower:upper);
}

template<typename T> inline bool v_find(vector<T> v,T object){
  auto itr = find(v.begin(), v.end(), object);
  size_t index = distance(v.begin(),itr);
  if (index != v.size()) { return true; } else { return false; }
}

template<class T,class U> inline auto LB(T& v,U in){ return lower_bound(v.begin(),v.end(),in); }
template<class T,class U> inline auto UB(T& v,U in){ return upper_bound(v.begin(),v.end(),in); }

int N,K;
ll frac[200002];

inline ll Comb(int n,int m){
	if(n<m||m<0) return 0;
	ll rev=Mpow(frac[m]*frac[n-m]%Mod,Mod-2,Mod);
	return rev*frac[n]%Mod;
}

inline void solve(){
	frac[0]=1;
	rep(i,K+N){
		frac[i+1]=frac[i]*(i+1)%Mod;
	}
	cout<<Comb(K+N-1,K)<<endl;
	return;
}

inline void input(){
	cin>>N>>K;
	return;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	solve();
	return 0;
}


Submission Info

Submission Time
Task D - 多重ループ
User jell
Language C++14 (GCC 5.4.1)
Score 100
Code Size 3469 Byte
Status AC
Exec Time 3 ms
Memory 1792 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 99 / 99 1 / 1
Status
AC × 5
AC × 23
AC × 33
Set Name Test Cases
Sample subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask0_sample_05.txt
Subtask1 subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt
All subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask0_sample_05.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt AC 1 ms 256 KB
subtask0_sample_02.txt AC 1 ms 256 KB
subtask0_sample_03.txt AC 1 ms 256 KB
subtask0_sample_04.txt AC 1 ms 256 KB
subtask0_sample_05.txt AC 3 ms 1792 KB
subtask1_01.txt AC 1 ms 256 KB
subtask1_02.txt AC 1 ms 256 KB
subtask1_03.txt AC 1 ms 256 KB
subtask1_04.txt AC 1 ms 256 KB
subtask1_05.txt AC 1 ms 256 KB
subtask1_06.txt AC 1 ms 256 KB
subtask1_07.txt AC 1 ms 256 KB
subtask1_08.txt AC 1 ms 256 KB
subtask1_09.txt AC 1 ms 256 KB
subtask1_10.txt AC 1 ms 256 KB
subtask1_11.txt AC 1 ms 256 KB
subtask1_12.txt AC 1 ms 256 KB
subtask1_13.txt AC 1 ms 256 KB
subtask1_14.txt AC 1 ms 256 KB
subtask1_15.txt AC 1 ms 256 KB
subtask1_16.txt AC 1 ms 256 KB
subtask1_17.txt AC 1 ms 256 KB
subtask1_18.txt AC 1 ms 256 KB
subtask1_19.txt AC 1 ms 256 KB
subtask2_02.txt AC 2 ms 896 KB
subtask2_03.txt AC 2 ms 1280 KB
subtask2_04.txt AC 2 ms 768 KB
subtask2_05.txt AC 2 ms 1536 KB
subtask2_06.txt AC 1 ms 512 KB
subtask2_07.txt AC 2 ms 1024 KB
subtask2_08.txt AC 2 ms 1408 KB
subtask2_09.txt AC 2 ms 1024 KB
subtask2_10.txt AC 3 ms 1792 KB