/ Randle /

记录详情

Compile Error

/in/foo.cc: In function 'll c(ll, ll)':
/in/foo.cc:24:2: error: 'ret' was not declared in this scope
  ret ans;
  ^~~
/in/foo.cc:24:2: note: suggested alternative: 'gets'
  ret ans;
  ^~~
  gets
/in/foo.cc:23:5: warning: unused variable 'ans' [-Wunused-variable]
  ll ans = ((fact[n]*ni(fact[m]))%mod)*ni(fact[n-m])%mod;
     ^~~
/in/foo.cc:25:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^

代码

#include <stdio.h>
#include <iostream>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll fact[200005];
ll quickPow(ll a,ll k){
	ll ret = 1,mc = a;
	while(k!=0){
		if(k&1){
			ret=ret*mc%mod;
			k--;
		}
		k = k/2; 
		mc = mc*mc%mod;
	}
	return ret%mod;
}
ll ni(ll a){
	return quickPow(a,mod-2);
}
ll c(ll n,ll m){
	ll ans = ((fact[n]*ni(fact[m]))%mod)*ni(fact[n-m])%mod;
	ret ans;
}
int main(){
	ll n,m;
	cin>>n>>m;
	fact[0] = 1;
	for(int i = 1;i<=n;i++){
		fact[i] = fact[i-1]*i%mod;
	}
	cout<<c(n,m);
	return 0;
}

信息

递交者
类型
递交
题目
电影 T1
题目数据
下载
语言
C++
递交时间
2017-10-15 18:26:57
评测时间
2017-10-15 18:26:57
评测机
分数
0
总耗时
328ms
峰值内存
29.746 MiB