/ Randle /

记录详情

Runtime Error

/in/foo.cc:47:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# 状态 耗时 内存占用
#1 Wrong Answer 3ms 320.0 KiB
#2 Wrong Answer 3ms 440.0 KiB
#3 Wrong Answer 2ms 320.0 KiB
#4 Wrong Answer 2ms 312.0 KiB
#5 Wrong Answer 2ms 448.0 KiB
#6 Wrong Answer 2ms 432.0 KiB
#7 Wrong Answer 1ms 572.0 KiB
#8 Runtime Error 2ms 324.0 KiB
#9 Runtime Error 2ms 312.0 KiB
#10 Runtime Error 1ms 308.0 KiB

代码

#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll base=1000000007;
ll n,k,a,v[300],num[300],other,ans=0ll;
ll f[300][300],fact[50001];

ll fast(ll a,ll b)
{
    ll res=1;
    while(b){
        if(b&1)res=res*a%base;
        b>>=1;
        a=a*a%base;
    }
    return res;
}
ll c(ll n,ll m)
{
    if(n>m)return 0;
    return fact[m]*fast(fact[m-n],base-2)%base*fast(fact[n],base-2)%base;
}

bool judge(ll b)
{
	ll a=b;
	int p;
	while(a>0)
	{
		p=a%10;
		if(p!=4&&p!=7)
			return false;
		a/=10;
	}
	for(p=1;p<=v[0];p++)
		if(num[p]==b)
		{
			v[p]++;
			return true;
		}
	num[++num[0]]=b;
	v[++v[0]]=1;
	return true;	
}
main()
{
	ll i,j;
	cin>>n>>k;
	for(i=1;i<=n;i++)
	{
		cin>>a;
		if(!judge(a))
			other++;
	}
	f[0][0]=1;
	for(i=1;i<=v[0];i++)
	{
		f[i][0]=1;
		for(j=1;j<=v[0];j++)
			f[i][j]=f[i-1][j]+f[i-1][j-1]*v[i];
	}
	for(i=1;i<=n;i++)
        fact[i]=fact[i-1]*i%base;
	for(i=0;i<=min(k,v[0]);i++)
		ans=(ans+f[v[0]][i]*c(other,k-i))%base;
	cout<<ans;
}

信息

递交者
类型
递交
题目
幸运数 T3
题目数据
下载
语言
C++
递交时间
2017-09-09 17:29:16
评测时间
2017-10-01 16:12:42
评测机
分数
0
总耗时
24ms
峰值内存
572.0 KiB