/ Randle /

记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Wrong Answer 2ms 2.309 MiB
#2 Wrong Answer 3ms 2.312 MiB
#3 Wrong Answer 2ms 2.305 MiB
#4 Wrong Answer 1ms 2.309 MiB
#5 Wrong Answer 1ms 316.0 KiB
#6 Wrong Answer 1ms 320.0 KiB
#7 Wrong Answer 2ms 2.309 MiB
#8 Wrong Answer 1ms 316.0 KiB
#9 Wrong Answer 1ms 316.0 KiB
#10 Wrong Answer 1ms 2.309 MiB

代码

#include<iostream>
#include<map>
#define maxn 100001
using namespace std;
typedef long long ll;
int P=1000000007;
int d=0,ans=0,tot=0,fact[maxn],nn,k,c[maxn],dp[2001][2001];
map<int,int>mp;
int fast(int a,int b)
{
	int rest=1;
	while(b)
	{
		if(b%2==1)
		rest=1ll*rest*a%P;
		a=1ll*a*a%P;
		b/=2;
	}
	return rest;
}
bool check(int x)
{
	if(x==0)
	return false;
	while(x)
	{
		int t=x%10;
		if(t!=4&&t!=7)
		return false;
		x=x/10;
	}
	return true;
}
int cale(int n,int m)
{
	if(n>m)
	return 0;
	return 1ll*fact[m]%P*fast(fact[n],P-2)%P*fast(fact[m-n],P-2)%P;
}
int main()
{
	freopen("lucky.in.txt","r",stdin);
	freopen("lucky.out.txt","w",stdout);
    int x;
    cin>>nn>>k;
    for(int i=1;i<=nn;i++)
    {
    	cin>>x;
    	if(check(x))
    		mp[x]++;
		else d++;
    }
	fact[0]=1;
	for(int i=1;i<=nn;i++)
		fact[i]=1LL*fact[i-1]*i%P;
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
		c[++tot]=it->second;
	for(int i=0;i<=nn;i++)
		dp[i][0]=1;
	for(int i=1;i<=tot;i++)
		for(int j=1;j<=i;j++)
		{
			dp[i][j]=(dp[i][j]+dp[i-1][j])%P;
			dp[i][j]=(dp[i][j]+1ll*dp[i-1][j-1]*c[i])%P;
		}
	for(int i=0;i<=min(tot,k);i++)
		ans=(ans+1ll*dp[tot][i]*cale(k-i,d))%P;
	cout<<ans<<endl;
	return 0;
}

信息

递交者
类型
递交
题目
幸运数 T3
题目数据
下载
语言
C++
递交时间
2017-09-15 20:27:37
评测时间
2017-09-15 20:27:49
评测机
分数
0
总耗时
20ms
峰值内存
2.312 MiB