大概率是我根本不会整除吧
算了,请求DALAO帮忙~
垃圾代码~~
#include<iostream>
#include<cmath>
using namespace std;
int main() {
int n = 0, b = 0, last = 0; //初始化变量
bool a = true; //这个判断i是否为质数,是则为true
//printf("%d", &n);
cin >> n;
for (int i = 2; i <= n; i++) {
//cout << i << " " << 9 << endl;
for (int j = 2; j < i; j++) {
//cout << i << " " << 11 << endl;
//cout << i << " " << j <<endl;
if (i % j == 0) {
a = false;
}
}
if (a) {
last = i; //上一个质数
//cout << i << " " << 16 << endl;
if (b <= n) { //判断是否超限
//cout << i << " " << 17 <<endl;
b++;
}
else {
cout << i - last << endl << b;//输出最后一个没有超限的质数
}
}
a = true;
}
return 0;
}
望DALAO忍住骂我的欲望
放过我玩这个小小白吧
求指出错误,谢谢~