#include <stdio.h>
typedef struct node
{
int prime;
node* next;
}Node;
void main()
{
Node *head=new Node;
Node *tail=head;
head->prime=2;
head->next=NULL;
int n;
__int64 sum=2;
scanf("%d",&n);
for(int i=2;i<n;i++)
{
Node *temp=head;
while(temp!=NULL)
{
if(i%temp->prime==0)
{
break;
}
temp=temp->next;
}
if(temp==NULL)
{
Node *add=new Node;
add->prime=i;
sum+=i;
add->next=NULL;
tail->next=add;
tail=add;
}
}
printf("%d",sum);
}
졸라느리네 ㅉㅉ
아까 댓글에 있던데?
sqrt 추가하면 된다는데?
N에 200만들어가면 오류되지않음?- From DC 도우미+
요즘 C 표준으로 안배우고 MSVC 기준으로 배움?