ZOJ 2829 Beautiful Number(睡前一水)

阅读 37

2022-07-29


链接:​​click here​​

题意:输出第N个能被3或者5整除的数,注意是||而不是&&.

代码:

<pre name="code" class="cpp">//zoj 2829
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;
const int maxn =0x3f3f3f;
int a[maxn];
int main()
{
int ans=1;
for(int i=3;i<maxn;i++)
if(i%3==0||i%5==0)
a[ans++]=i;
int b;
while(cin>>b)
{
cout<<a[b]<<endl;
}
return 0;
}






精彩评论(0)

0 0 举报