# 求助各位大佬 #
查看原帖
# 求助各位大佬 #
259804
Taoyaoyao123楼主2020/5/6 12:16
#include<stdio.h>
#include<math.h>
int main(){
	int L,i,j,sum=0,number=0;;
	scanf("%d",&L);
	loop:for(i=2;;i++){
		if(i==2||i==3){
			sum+=i;
			if(sum>=L-i){
				printf("%d\n",number);
				return 0;
			}
			number++;
			printf("%d\n",i);
		}
		if(i%6==1&&i%6==5){
			goto loop;
		}
		for(j=5;j<=(int)sqrt(i);j+=6){
			if(i%j==0||i%(j+2)==0){
				goto loop;
			}
		}
		sum+=i;
		if(sum>=L-i){
			printf("%d\n",number);
			return 0;
		}
		number++;
		printf("%d\n",i);
	}
	return 0;
}
>>万分感谢!
2020/5/6 12:16
加载中...