/ Randle /

记录详情

Time Exceeded

/in/foo.cc: In function 'int main()':
/in/foo.cc:20:9: warning: statement has no effect [-Wunused-value]
     a[i]==o;
     ~~~~^~~
/in/foo.cc:21:9: warning: statement has no effect [-Wunused-value]
     a[j]==0;
     ~~~~^~~
# 状态 耗时 内存占用
#1 Accepted 25ms 380.0 KiB
#2 Accepted 92ms 208.0 KiB
#3 Accepted 36ms 364.0 KiB
#4 Accepted 61ms 368.0 KiB
#5 Accepted 62ms 384.0 KiB
#6 Accepted 52ms 372.0 KiB
#7 Accepted 149ms 264.0 KiB
#8 Accepted 133ms 340.0 KiB
#9 Time Exceeded ≥1004ms ≥368.0 KiB
#10 Time Exceeded ≥1004ms ≥340.0 KiB

代码

#include<iostream>
#include<cmath>
using namespace std;
int a[25],b[7000];
long long int m,n,sum;
int t=0;
int main()
{
	cin>>n>>m;
	sum=n;
	for(int i=1;i<=m;i++)cin>>a[i];
	for(int i=1;i<m;i++)
   {
	 for(int j=i;j<=m;j++)
	  {
	 	int o=min(a[i],a[j]);
	 	int p=max(a[i],a[j]);
	 	if(p%o==0&&o!=0)
	 	{
	 		a[i]==o;
	 		a[j]==0;
	 
	    }
     }
   }
   for(int i=1;i<=m;i++)
   {if(a[i]!=0)b[++t]=a[i];
   }
 //   for(int i=1;i<=t;i++)cout<<b[i]<<" "<<endl;
	for(int i=1;i<=t;i++)
	{
		int o=1;
		while(o*b[i]<=n)
		{
			int p=0;
			int u=o*b[i];
			for(int j=1;j<i;j++)
			{
				if(u/b[j]!=0&&u%b[j]==0)p=1;
			}
			if(p==0)sum--;
			o++;
//			cout<<o<<"  o  "<<endl;
//			cout<<b[i]<<"  b[i]   "<<endl;
//			cout<<o*b[i]<<" o*b[i]  "<<endl;
//			cout<<p<<" p  "<<endl;
//			cout<<sum<<" sum  "<<endl;
		}
	}
	cout<<sum;
	return 0;
}

信息

递交者
类型
递交
题目
计数 T1
题目数据
下载
语言
C++
递交时间
2018-08-23 12:23:16
评测时间
2018-08-23 12:23:16
评测机
分数
80
总耗时
≥2622ms
峰值内存
≥384.0 KiB