关于在线性筛中使用__int128
  • 板块学术版
  • 楼主hh弟中弟
  • 当前回复12
  • 已保存回复14
  • 发布时间2024/9/11 15:21
  • 上次更新2024/9/11 20:30:38
查看原帖
关于在线性筛中使用__int128
366639
hh弟中弟楼主2024/9/11 15:21
#include<bits/stdc++.h>
#define int __int128
typedef long long ll;
typedef unsigned long long ull;
inline int read(){char ch=getchar();int x=0,f=1;for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);return x*f;}
int vis[1000],p[1000],tot;
signed main(){
	freopen("in.in","r",stdin);freopen("out.out","w",stdout);
	std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
	int n=10;
	for(int i=2;i<=n;++i){
		if(!vis[i])p[++tot]=i;
		for(int j=1;p[j]*i<=n;++j){
			int x=p[j]*i;
			vis[x]=1;
			if(i%p[j]==0)break;
		}
	}
}

这份代码会在 if(i%p[j]==0) 语句 RE,关了 __int128 就没事,求教教。

2024/9/11 15:21
加载中...