Description
Mike is very lucky, as he has two beautiful numbers, 3 and 5. But he is so greedy that he wants infinite beautiful numbers. So he declares that any positive number which is dividable by 3 or 5 is beautiful number. Given you an integer N (1 <= N <= 100000), could you please tell mike the Nth beautiful number?
Input
The input consists of one or more test cases. For each test case, there is a single line containing an integer N.
Output
For each test case in the input, output the result on a line by itself.
Sample Input
1
2
3
4
Sample Output
3
5
6
9
题目介绍
规定所有能被三或五整除的正整数都算漂亮数字,输入一个整数,输出第N个漂亮数字
解题思路
就是判断被三或五能否整除
源代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<int> a;
int i,n,k;
for(i=1,k=0;k<=100000;i++)
{
if(i%3==0||i%5==0)
{
a.push_back(i);
k++;
}
}
while(cin>>n)
cout<<a[n-1]<<endl;
return 0;
}
重要的事情说三遍,注意读题,注意读题,注意读题。