「杂题乱刷」AT_abc096_d

对下脑电波。

题目链接(luogu)

题目链接(at)

发现我们可以找出所有 \(x\) 当且仅当 \(x\) 为质数且 \(x \bmod 5 = 3\),这样任意五个数加起来就必定为合数了。

代码:

点击查看代码
/*
Tips:
你数组开小了吗?
你MLE了吗?
你觉得是贪心,是不是该想想dp?
一个小时没调出来,是不是该考虑换题?

记住,rating 是身外之物。

该冲正解时冲正解!
*/
#include<bits/stdc++.h>
using namespace std;
#define map unordered_map
#define forl(i,a,b) for(register long long i=a;i<=b;i++)
#define forr(i,a,b) for(register long long i=a;i>=b;i--)
#define forll(i,a,b,c) for(register long long i=a;i<=b;i+=c)
#define forrr(i,a,b,c) for(register long long i=a;i>=b;i-=c)
#define lc(x) x<<1
#define rc(x) x<<1|1
//#define mid ((l+r)>>1)
#define cin(x) scanf("%lld",&x)
#define cout(x) printf("%lld",x)
#define lowbit(x) x&-x
#define pb push_back
#define pf push_front
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define endl '\n'
#define QwQ return 0;
#define ll long long
#define ull unsigned long long
#define lcm(x,y) x/__gcd(x,y)*y
#define Sum(x,y) 1ll*(x+y)*(y-x+1)/2
#define aty cout<<"Yes\n";
#define atn cout<<"No\n";
#define cfy cout<<"YES\n";
#define cfn cout<<"NO\n";
#define xxy cout<<"yes\n";
#define xxn cout<<"no\n";
ll t;
ll a[60],k;
bool pdzs(long long a)
{
    if(a==1)
        return 0;
    if(a==2)
        return 1;
    for(long long i=2;i<=sqrt(a);i++)
        if(a%i==0)
            return 0;
    return 1;
}
ll n;
bool check(ll x)
{
	if(k<=3)
		return 1;
	forl(i,1,k)
		forl(j,i+1,k)
			forl(l,j+1,k)
				forl(r,l+1,k)
					if(pdzs(x+a[i]+a[j]+a[l]+a[r])==0)
						return 0;
	return 1;
}
void solve()
{
	cin>>n;
	ll sum=0;
	forl(i,3,1145141919810233ll)
		if(pdzs(i) && i%5==3)
		{
			sum++;
			cout<<i<<' ';
			if(sum==n)
				return ;
		}
}
int main()
{
	srand(time(0));
	IOS;
	t=1;
//	cin>>t;
	while(t--)
		solve();
    /******************/
	/*while(L<q[i].l) */
	/*    del(a[L++]);*/
	/*while(L>q[i].l) */
	/*    add(a[--L]);*/
	/*while(R<q[i].r) */
	/*	  add(a[++R]);*/
	/*while(R>q[i].r) */
	/*    del(a[R--]);*/
    /******************/
	QwQ;
}
posted @ 2024-05-05 22:10  wangmarui  阅读(2)  评论(0编辑  收藏  举报