#include <stdio.h>
int main(){
int n,i,temp=2;
int sol[500001];
sol[0]=0;
sol[1]=1;
sol[2]=2;
for(i=3;i<500001;i++,temp+=2){
if(i<temp)
temp=2;
sol[i]=temp;
}
while(1){
scanf("%d",&n);
if(n==0)
break;
printf("%d\n",sol[n]);
}
return 0;
}
int main(){
int n,i,temp=2;
int sol[500001];
sol[0]=0;
sol[1]=1;
sol[2]=2;
for(i=3;i<500001;i++,temp+=2){
if(i<temp)
temp=2;
sol[i]=temp;
}
while(1){
scanf("%d",&n);
if(n==0)
break;
printf("%d\n",sol[n]);
}
return 0;
}
No comments:
Post a Comment