/ Randle /

记录详情

Accepted

/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 5ms 2.25 MiB
#2 Accepted 3ms 2.348 MiB
#3 Accepted 3ms 2.25 MiB
#4 Accepted 2ms 368.0 KiB
#5 Accepted 2ms 372.0 KiB
#6 Accepted 6ms 2.375 MiB
#7 Accepted 3ms 2.375 MiB
#8 Accepted 26ms 364.0 KiB
#9 Accepted 79ms 2.75 MiB
#10 Accepted 64ms 2.719 MiB

代码

#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long n,k,jishu,tot,sum[1024],xuanzhe[200000],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:55:24
评测时间
2018-04-19 11:55:24
评测机
分数
100
总耗时
197ms
峰值内存
2.75 MiB