View Code of Problem 31

#include<iostream>
using namespace std;
int main() {
	int k,count,i;
	while (cin >> k) {
		count = 0;//记录符合条件的数的个数
		i = 23;//符合条件的数
		while (count < k) {//符合的数没达到k个
			if (i % 3 == 2 && i % 5 == 3 && i % 7 == 2) {
				count++;
			}
			i=i+105;
		}
		cout << i-105 << endl;
	}
	
	return 0;
}

Double click to view unformatted code.


Back to problem 31