/ Randle /

记录详情

Runtime Error

/in/foo.cc:63:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# 状态 耗时 内存占用
#1 Accepted 3ms 336.0 KiB
#2 Accepted 2ms 340.0 KiB
#3 Accepted 3ms 256.0 KiB
#4 Accepted 2ms 344.0 KiB
#5 Accepted 3ms 256.0 KiB
#6 Time Exceeded ≥1003ms ≥328.0 KiB
#7 Time Exceeded ≥1003ms ≥256.0 KiB
#8 Runtime Error 14ms 8.25 MiB
#9 Runtime Error 58ms 8.352 MiB
#10 Runtime Error 74ms 8.332 MiB

代码

#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,total=1ll,ans=0ll;

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;	
}
ll c(ll a,ll b)
{
	if(a<b)
		return 0;
	if(b==1)
		return a;
	if(a==b||b==0)
		return 1;
	return c(a-1,b)+c(a-1,b-1);
}
void work(int step,int now)
{
	if(now>k)	return ;
	if(step>v[0])
	{
		ans=ans+total*c(other,k-now);
		ans%=base;
	}
	else 
	{
		for(int i=0;i<=1;i++)
		{
			if(i==0)
				work(step+1,now);
			else
			{
				total*=v[step];
				work(step+1,now+1);
				total/=v[step];
			}
		}
	}
}
main()
{
	int i;
	cin>>n>>k;
	for(i=1;i<=n;i++)
	{
		cin>>a;
		if(!judge(a))
			other++;
	}
	work(1,0);
	cout<<ans;
}

信息

递交者
类型
递交
题目
幸运数 T3
题目数据
下载
语言
C++
递交时间
2017-09-09 15:46:29
评测时间
2017-09-09 15:46:29
评测机
分数
50
总耗时
2169ms
峰值内存
8.352 MiB