View Code of Problem 31

#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
	int k;
	while(cin >> k)
	{
		int i = 1, count = 0;
		while(1)
		{
			long long ans = i * 21;
			ans += 2;
			if(ans % 5 == 3)
				count++;
			if(count == k)
			{
				cout << ans << endl;
				break;
			}
			i++;
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 31