View Code of Problem 31

#include<stdio.h>

//找出第k个被3,5,7除的时候,余数为2,3,2的数——算法导论 

//1  23
//2  128
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		int flag;
		scanf("%d",&flag);
		int i = 9,count = 0;
		while(i){
			if(i%3==2&&i%5==3&&i%7==2)
				count++;
			if(count==flag){
				printf("%d\n",i);
				break;
			}
			
			i++;
		}
		
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 31