/ Randle /

记录详情

Runtime Error

/in/foo.cc: In function 'long long int C()':
/in/foo.cc:22:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
# 状态 耗时 内存占用
#1 Accepted 2ms 384.0 KiB
#2 Accepted 2ms 356.0 KiB
#3 Accepted 3ms 364.0 KiB
#4 Accepted 2ms 376.0 KiB
#5 Accepted 2ms 372.0 KiB
#6 Wrong Answer 4ms 344.0 KiB
#7 Wrong Answer 4ms 356.0 KiB
#8 Wrong Answer 11ms 368.0 KiB
#9 Runtime Error 54ms 484.0 KiB
#10 Runtime Error 80ms 480.0 KiB

代码

#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long n,k,jishu,tot,sum[1024],xuanzhe[1024],c[200000];
long long qpow(long long a,long long b)
{
	long long ans=1;
	while(b!=0)
	{
		if(b&1)
		ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
long long C()
{
	c[0]=1;
    for(int i=1;i<=jishu;i++)
        c[i]=c[i-1]*(jishu-i+1)%mod*qpow(i,mod-2)%mod;
}
long long luck[1024],cnt;
void dfs(long long k,long long dep)
{  
    if(k)
	luck[++cnt]=k;
    if (dep==10)
	return;
    dfs(k*10+4,dep+1);
    dfs(k*10+7,dep+1);  
}  
int main()
{
	//freopen("lucky.in","r",stdin);
	//freopen("lucky.out","w",stdout);
	cin>>n>>k;
	dfs(0,1);
	sort(luck+1,luck+1+cnt);
	jishu=n;
	for(long long i=1;i<=n;++i)
	{
		long long h;
		cin>>h;
		long long weizhi=lower_bound(luck+1,luck+1+cnt,h)-luck;
		if(luck[weizhi]==h)
		sum[weizhi]++;
		if(sum[weizhi]==2)
		jishu-=2;
		else
		if(sum[weizhi]>2)
		jishu--;
	}
	xuanzhe[0]=1;
	for(long long i=1;i<=cnt;++i)
		if(sum[i]>=2)
			for(long long j=i;j>=1;--j)
			xuanzhe[j]=(xuanzhe[j]+xuanzhe[j-1]*sum[i])%mod;
	C();
	for(long long i=0;i<=k;++i)
	if(i<=jishu)
	tot=(tot+c[i]*xuanzhe[k-i]%mod)%mod;
	cout<<tot;
	return 0;
}

信息

递交者
类型
递交
题目
幸运数 T3
题目数据
下载
语言
C++
递交时间
2018-04-19 11:47:04
评测时间
2018-04-19 11:47:04
评测机
分数
50
总耗时
168ms
峰值内存
484.0 KiB