View Code of Problem 31

#include<iostream>
using namespace std;
int main(){
	int k;
	while(cin>>k){
		int a[10000],n=0;
	for(int i=23;;i=i+105){
			if((i-2)%3==0&&(i-3)%5==0&&(i-2)%7==0)
			{
				n++;
			}
			if(k==n){
				cout<<i<<endl;
				break;
			}
		}
		
//		cout<<23+105*(k-1)
	}
	return 0;
}
 

Double click to view unformatted code.


Back to problem 31