/ Randle /

记录详情

Time Exceeded


  
# 状态 耗时 内存占用
#1 Time Exceeded ≥1007ms ≥312.0 KiB
#2 Time Exceeded ≥1007ms ≥312.0 KiB
#3 Time Exceeded ≥1007ms ≥312.0 KiB
#4 Time Exceeded ≥1007ms ≥312.0 KiB
#5 Time Exceeded ≥1007ms ≥308.0 KiB
#6 Time Exceeded ≥1006ms ≥316.0 KiB
#7 Time Exceeded ≥1006ms ≥308.0 KiB
#8 Time Exceeded ≥1008ms ≥312.0 KiB
#9 Time Exceeded ≥1006ms ≥320.0 KiB
#10 Time Exceeded ≥1006ms ≥308.0 KiB

代码

#include<bits/stdc++.h>
const long long maxn=300001,mod=1e9+7;
inline const void read(long long &a)
{
	a=0;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')
	{
		a=(a<<1)+(a<<3)+c-'0';
		c=getchar();
	}
}
inline const void write(long long a)
{
	if(a>=10)write(a/10);
	putchar(a%10+'0');
}
inline const bool lucky(long long a)
{
	bool r=true;
	long long k=a;
	while(k)
	{
		long long c=k%10;
		if(c!=7&&c!=4)
		{
			r=false;
			break;
		}
		k/=10;
	}
	return r;
}
long long n,a[maxn],k,ans=0;
bool luck[maxn];
struct LUCK_WORD
{
	long long l[maxn],end,num[maxn];
	inline const void init(){end=0;memset(num,0,sizeof(num));}
	inline const void push(long long cc)
	{
		for(long long i=1;i<=end;i++)if(l[i]==cc){num[i]++;return ;}
		l[++end]=cc;
		num[end]=1;
	}
	inline const bool can()
	{
		for(long long i=1;i<=end;i++)if(num[i]==2)return false;
		return true;
	} 
}line;
int main()
{
	freopen("lucky.in","r",stdin);
	read(n);read(k);
	for(long long i=1;i<=n;i++)
	{
		read(a[i]);
		luck[i]=lucky(a[i]);
	}
	for(long long i=1;i<=1<<n;i++)
	{
		line.init();
		long long r=0;
		for(long long p=1;p<=n;p++)
			if(i&(1<<(p-1)))
			{
				if(luck[p])line.push(a[p]);
				r++;
			}
		if(r==k&&line.can())ans++;
	}
	write(ans);
	return 0;
}

信息

递交者
类型
递交
题目
幸运数 T3
题目数据
下载
语言
C++
递交时间
2017-09-09 15:43:22
评测时间
2017-10-01 16:12:45
评测机
分数
0
总耗时
≥10072ms
峰值内存
≥320.0 KiB