当前位置:网站首页>OJ 1131 beautiful number
OJ 1131 beautiful number
2022-07-28 06:38:00 【JETECHO】
describe
Xiao Ming likes 3 and 5 These two numbers , He will be able to be 3 or 5 The number of integral division is called beautiful number . Now I'll give you an integer N(1<=N<=100000), Can you tell xiaomingdi N What is the number of beauties ?
Input
Input contains multiple sets of test data . Enter an integer for each group N(1<=N<=100000).
Output
For each group of input , Output No N A beautiful number .
sample input 1
1
2
3
4
sample output 1
3
5
6
9
The title requires finding out the number of beautiful numbers , Then we can first The meter , Then output directly
#include <iostream>
using namespace std;
long long a[100001];
int j=1;
void creat()
{
a[j++]=3;long long i=4;
while(j<=100000)
{
if(i%3==0||i%5==0)
a[j++]=i;
i++;
}
}
int main()
{
creat();
int n;
while(cin>>n)
cout<<a[n]<<endl;
return 0;
}
边栏推荐
猜你喜欢

【动态规划--买卖股票的最佳时期系列3】

What's a good gift for your girlfriend on the Chinese Valentine's day in 2022? Practical and beautiful gift recommendation

Listener

Leetcode 刷题日记 剑指 Offer II 055. 二叉搜索树迭代器

QT implementation outputs relevant information to log file

Leetcode 刷题日记 剑指 Offer II 050. 向下的路径节点之和

Several methods of QT setting loading interface

七夕送什么礼物最实用?送人绝对不会出错的礼物值得买

NFT data storage blind box + mode system development

刷题记录----二叉树的层序遍历
随机推荐
Listener
NFT data storage blind box + mode system development
Leetcode 刷题日记 剑指 Offer II 055. 二叉搜索树迭代器
scrapy 定时执行
OJ 1018 报数游戏
Servlet
空气传导耳机哪个牌子好、备受好评的气传导耳机推荐
关于时间复杂度,你不知道的都在这里
【学习笔记】工具
2022-07-19 达梦数据库 连接实例、执行脚本、系统命令
【二叉树基础知识】
2022-05-24 use of spiel
2022-06-07 ResponseBodyAdvice导致Swagger出现弹框问题
到底什么是Hash?(量化交易机器人系统开发)
error: redefinition of ‘xxx‘
2022-06-07 六.日志实现
战疫杯--我的账本
Relative path and absolute path
JSON笔记
[PTA----树的遍历]