View Code of Problem 31

#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {


	int k ;
	scanf("%d" , &k);
	//找出第k个被3,5,7除的时候,余数为2,3,2的数——
	int count = 0;
	int num = 9;
	while(true) {
		if( num % 3 == 2 && num % 5 ==3 && num % 7 ==2   )
			count++;
		if(count == k) {
			printf("%d" , num);
			break ;
		}
		num++;
	}

	return 0 ;
}

Double click to view unformatted code.


Back to problem 31