当前位置:网站首页>P5723 [deep base 4. example 13] prime number pocket
P5723 [deep base 4. example 13] prime number pocket
2022-06-10 20:35:00 【&volume】
Catalog
subject :
Small A There is a prime pocket , It can hold all prime numbers . He from 22 Start , Judge whether each natural number is a prime number in turn , If it's a prime number, you'll put this number in your pocket . The load of the pocket is the sum of all the numbers in the pocket . But the weight of the pocket is limited , You can't fit more than LL(1 \le L \le {10}^51≤L≤105) The prime number of . give LL, How many prime numbers can you hold in your pocket ? Output these prime numbers from small to large , Then output the maximum number of prime numbers that can be installed , There is a blank line between all the numbers .
Input format
One positive integer per line LL.
Output format
Output these prime numbers from small to large , Then output the maximum number of prime numbers that can be installed , There is a blank line between all the numbers .
I/o sample
Input #1 Copy
100
Output #1 Copy
2 3 5 7 11 13 17 19 23 9
Code :
# include <stdio.h>
int main()
{
int n;
scanf("%d",&n);
if(n<2)
{
printf("0");
return 0;
}
int y=3;
int s=2,i,c=1;
printf("%d\n",s);
while (1)
{
for(i=2;i<y;i++)
{
// printf("kkkkkkkkkkkkkkkkk");
if(y%i==0)
{
y++;
// printf("%d",y);
break;
}
} // Judge whether the prime number is no
if(i==y)
{//printf("kkkkkkkkkk");
// printf("%d %d %d",s,y,n);
if(s+y<=n)
{
s+=y;
printf("%d\n",y);
y++;
c++;
}
else
{
printf("%d",c);
break;
}
}
}
return 0;
} Knowledge summary :
Just a judging prime number , Focus on less than 2 In special circumstances ( There are tests in the code , Please ignore )
边栏推荐
- 如何使用物联网低代码平台进行工作表管理?
- Jiangbolong forestee xp2000 PCIe 4.0 SSD multi encryption function, locking data security
- Mixin -- mixed
- 一个10年左右的老程序员说:简单CRUD功能进入无码开发时代1 之 增删改查接口信息
- 测试apk-异常管控netLocation攻击者开发
- 详解三级缓存解决循环依赖
- When can Flink support the SQL client mode? When can I specify the applicati for submitting tasks to yarn
- HM3416H降压IC芯片PWM/PFM 控制 DC-DC 降压转换器
- Redis集群形式--哨兵模式集群和高可用模式集群---Redis学习笔记003
- 国家先进计算产业创新(宜昌)中心正式落地 中科曙光、升哲科技联合运营
猜你喜欢

It took 2 years, 442 authors and 132 institutions! Google released the new benchmark big bench for language model evaluation. 204 tasks comprehensively evaluated the language model ability, with paper

解决idea超过5个相同包的时候自动变成*的问题

【技术碎片】重名文件 加后缀重命名过滤实现

获取列表中最大最小值的前n个数值的位置索引的四种方法

一个10年左右的老程序员说:简单CRUD功能进入无码开发时代1 之 增删改查接口信息

How to use the low code platform of the Internet of things for worksheet management?

Canvas advanced functions (Part 1)

Zabbix_监控ssh/crond服务-微信告警

vulnhub-The Planets: Earth

传音 Infinix 新机现身谷歌产品库,TECNO CAMON 19 预装 Android 13
随机推荐
8.4v双节锂电池专业充电ic(FS4062A)
Redis cluster form - sentry mode cluster and high availability mode cluster - redis learning notes 003
latex tips 绝对值的竖线 \left|\right|
AttributeError: module ‘collections‘ has no attribute ‘MutableMapping‘
Zabbix_ Principle Architecture - installation and deployment - Custom monitoring
Rotated Sorted Array旋转排序数组相关题
ESP8266 系统环境搭建
Canvas advanced functions (Part 1)
FS2117升压IC输出5V2.4A同步整流
vulnhub-The Planets: Earth
[technical fragment] implementation of renaming and filtering duplicate name files with suffixes
Fs2117 boost IC output 5v2.4a synchronous rectification
玩艺术也得学数学?
暗黑破坏神不朽WIKI地址 暗黑破坏神不朽数据库地址分享
详解三级缓存解决循环依赖
Knife4j configuration can use direct copy
Kp522201a adopts SOT23-6 encapsulated 4.5V to 17V input, 2A output, 600kHz synchronous step-down converter
MBA-day21 线性规划问题
I drew several exquisite charts with plotly, which turned out to be beautiful!!
KP522201A采用 SOT23-6 封装的 4.5V 至 17V 输入、2A 输出、600kHz 同步降压转换器