/ Randle /

记录详情

Runtime Error

/in/foo.cc: In function 'int main()':
/in/foo.cc:51:19: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   scanf("%I64d",&h);
                   ^
# 状态 耗时 内存占用
#1 Accepted 2ms 368.0 KiB
#2 Accepted 3ms 384.0 KiB
#3 Wrong Answer 4ms 356.0 KiB
#4 Accepted 2ms 376.0 KiB
#5 Wrong Answer 3ms 368.0 KiB
#6 Wrong Answer 5ms 256.0 KiB
#7 Wrong Answer 24ms 384.0 KiB
#8 Wrong Answer 219ms 360.0 KiB
#9 Runtime Error 76ms 384.0 KiB
#10 Runtime Error 65ms 376.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];
long long a[3];
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(long long a,long long b)
{
	long long ans=1,j=1;
	for(long long i=a;i>=a-b+1;--i)
	{
		ans=ans*i*qpow(j,mod-2);
		ans%=mod;
		j++;
	}
	return ans%mod;
}
long long luck[1024],cnt;
void dfs(long long k,long long dep)
{  
    if(k)
	luck[++cnt]=k;
    if (dep>9)
	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;
		scanf("%I64d",&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;
	for(long long i=0;i<=k;++i)
	if(i<=jishu)
	tot=(tot+C(jishu,i)*xuanzhe[k-i]%mod)%mod;
	cout<<tot;
	return 0;
}

信息

递交者
类型
递交
题目
幸运数 T3
题目数据
下载
语言
C++
递交时间
2018-04-17 19:55:45
评测时间
2018-04-17 19:55:45
评测机
分数
30
总耗时
408ms
峰值内存
384.0 KiB