View Code of Problem 80

#include <stdio.h>
main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		if(n == 0)
			break;
		int a[100]={0},i,j,k=1,N = 0;
		for(i =0;;i++){
			for(j =0;j<n;j++){
				if(a[j] != 0)
					continue;
				if(k%3==0){
					a[j] = 1;
					N++;
				}
					k++;
			}
			if(N == n-1)
				break;
		}
		for(i=0;i<n;i++){
			if(a[i]==0){
				printf("%d\n",i+1);
				break;
			}
			
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 80