HDU-2710 Max Factor

zabbix监控深信服下一代防火墙配置 深信服下一代防火墙v8.0管理界面,zabbix,SNMP 阅读详情

HDU-2710 Max Factor

Time Limit : 2000/1000ms (Java/Other)
Memory Limit : 32768/32768K (Java/Other)
 

Problem Description

To improve the organization of his farm, Farmer John labels each of his N (1 <= N <= 5,000) cows with a distinct serial number in the range 1..20,000. Unfortunately, he is unaware that the cows interpret some serial numbers as better than others. In particular, a cow whose serial number has the highest prime factor enjoys the highest social standing among all the other cows.
(Recall that a prime number is just a number that has no divisors except for 1 and itself. The number 7 is prime while the number 6, being divisible by 2 and 3, is not).
Given a set of N (1 <= N <= 5,000) serial numbers in the range 1..20,000, determine the one that has the largest prime factor.
 

Input
  • Line 1: A single integer, N * Lines 2..N+1: The serial numbers to be tested, one per line
     
Output
  • Line 1: The integer with the largest prime factor. If there are more than one, output the one that appears earliest in the input file.
     
Sample Input
4
36
38
40
42
Sample Output
38

 
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=2710
 

分析

题意:首先输入一个数字N,接下来N行,每行输入1个数字,求出每个数字的最大素数因子,如果两个数的最大素数因子相等,则取先出现的数字。
 
思路:很简单,只用求它的因子就行了(从大到小求),然后判断一下是不是素数就行了。然后我再说一下坑点,首先这是个多实例测试,我早就应该想到的,杭电就不可能出现单实例,导致我WA了两次。然后就是这里的1也算成了素数。
 

代码
#include <iostream>
#include <stdio.h>
using namespace std;
int num[5005];
int vis[20001]={0};
int j=0;
void Prime()
{
    for (int i=2;i<20001;i++)
    {
        if (vis[i])
            continue;
        for (int k=2;k*i<20001;k++)
            vis[k*i]=1;
    }
}
int main()
{
    int n;
    Prime();
    while (~scanf("%d",&n))
    {
        int maxx=0,num=1;
        for (int i=0;i<n;i++)
        {
            int flag=1;
            int a;
            cin>>a;
            for (int k=1;k<a;k++)
            {
                if (a%k==0&&!vis[a/k])
                {
                    flag=a/k;
                    break;
                }
            }
            if (maxx<flag)
            {
                maxx=flag;
                num=a;
            }
        }
        cout<<num<<endl;
    }
    return 0;
}
VisionMaster4.2.0与C#控件开发实战:从入门到精通的完整指南 本文详细介绍了VisionMaster4.2.0与C#控件开发的实战指南,从基础环境搭建到核心控件使用,再到高级功能实现。通过VmFrontendControl、VmGlobalToolControl等核心控件的深入解析,帮助开发者快速掌握机器视觉应用开发技巧,提升开发效率。特别适合需要集成VisionMaster4.2.0 SDK进行视觉系统开发的C#程序员。 阅读详情

相关推荐

Rust Reqwest+Rustls 自签名证书校验

所以这里必须保证reqwest引用的rustls库和本地工程一致。以上就是实现不校验签名的逻辑,后续自己可以在对应回调进行逻辑判断。

bawomingtian123的专栏 1380

HDU 2710 Max Factor (水题)

Max Factor Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2238    Accepted Submission(s): 684 Problem Description To improve the organizatio...

weixin_33958366的博客 118

RAID 0/1/5/10 性能实测:4块 SATA SSD 组阵列,顺序读写速度对比

本文通过实测对比了RAID 0/1/5/10在4块SATA SSD上的顺序读写性能,详细展示了不同RAID级别的配置方法、理论性能与实际测试数据。测试结果显示,RAID 0在顺序读写速度上表现最佳,而RAID 10则在性能与数据安全之间取得了平衡,适合数据库服务器等关键应用场景。

weixin_33462167的博客 431

HDU - 2710 - Max Factor【 筛法求素数 】题解

目录1.题目2.代码 1.题目 To improve the organization of his farm, Farmer John labels each of his N (1 <= N <= 5,000) cows with a distinct serial number in the range 1…20,000. Unfortunately, he is unaware that the cows interpret some serial numbers as better t

林深不见鹿 的博客 467

大数据应用技术实验报告一 Hadoop三种模式安装配置

JDK+Hadoop安装配置、单机模式配置 以下操作在SecureCRT里面完成 1.关闭防火墙 firewall-cmd --state 显示防火墙状态running/not running systemctl stop firewalld 临时关闭防火墙,每次开机重新开启防火墙 systemctl disable firewalld 禁止防火墙服务。 2.传输JDK和HADOOP压缩包 Sec...

Ruthless_Childe的博客 3098

ceph recovery 相关参数

可以修改的最大回填/恢复选项列在 “恢复/回填选项” 部分。mClock 的修改 默认回填/恢复限制由 osd_mclock_override_recovery_settings 选项,设置为 默认为 false。尝试修改任何默认恢复/回填限制而不设置门控选项,会将该选项重置为 mClock 默认值,并在集群日志中记录一条警告消息。请注意,默认值可能需要几秒钟才能恢复生效。请使用 config show 命令验证限制,如下所示。就直接设置以下参数,过一会就变回了默认值。简单点说官网的意思就是不设置。

weixin_40548182的博客 282

POJ - 3048 (最大素因数)

To improve the organization of his farm, Farmer John labels each of his N (1 <= N <= 5,000) cows with a distinct serial number in the range 1..20,000. Unfortunately, he is unaware that the cows interp

a1046765624的博客 620

【ESP 保姆级教程】玩转emqx数据集成篇④ ——数据桥接之HTTP服务

主要是学习数据桥接功能以及构建自己的http服务器,这是一个非常有用的功能。包括各种传感器上报基本上都需要数据桥接功能支持,所以还是希望认真学习这一块开发,然后结合数据库存储等等知识点进行进一步学习。

单片机菜鸟哥的博客 1309

POJ - 3048 区间数的最大质因子

To improve the organization of his farm, Farmer John labels each of his N (1 &lt;= N &lt;= 5,000) cows with a distinct serial number in the range 1..20,000. Unfortunately, he is unaware that the cows ...

Feynman1999的博客 802

国科大学习资料--自然语言处理(宗成庆)-2019期末考试题

国科大学习资料–自然语言处理(宗成庆)-2019期末考试题 国科大学习资料–自然语言处理(宗成庆)-2019期末考试题 国科大学习资料–自然语言处理(宗成庆)-2019期末考试题

无名何许人的博客 2444

YOLOv8改进 | Conv篇 | DWRSeg扩张式残差助力小目标检测 (附修改后的C2f+Bottleneck)

本文内容给大家带来的DWRSeg中的DWR模块来改进YOLOv8中的C2f和Bottleneck模块,主要针对的是小目标检测,主要创新点可以总结如下:多尺度特征提取机制的深入研究和创新的DWR模块和SIR模块的提出这种方法使得网络能够更灵活地适应不同尺度的特征,从而更准确地识别和分割图像中的物体。通过本文你能够了解到DWRSeg的基本原理和框架,并且能够在你自己的网络结构中进行添加(DWRSeg需要增加一定的计算量一个DWR模块大概增加0.4GFLOPs)。

Snu77的博客 9583

素数筛选法2

Max Factor Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4782 Accepted: 1865 Description To i

875

人工智能训练师三级·模型生命周期真题40题|训练→评估→调优全链路通关

本文为人工智能训练师三级考试真题解析系列第2篇,聚焦模型生命周期全链路(训练→评估→调优)。内容包含40道精选真题,覆盖数据划分、模型训练、评估指标、超参数调优4个核心阶段。重点考察:1)数据集的合理划分方法(留出法、交叉验证);2)模型训练的基本原理;3)关键评估指标(准确率、召回率、F1等)的应用场景;4)超参数调优技术(网格搜索、随机搜索等)。通过真题解析帮助考生系统掌握模型生命周期的闭环迭代方法论,提升从数据准备到模型优化的全流程实践能力。适合备考人工智能训练师三级认证的考生学习参考。

白话机器学习 102

hdu 2710 Max Factor

hdu 2710 Max Factor 水题写了一上午,还是打表的,开始,打表还超时,看了一下别人的打表,加了一个 !!=EOF    ,就过了。     先贴打表代码:    #include #include #include #include using namespace std; int main() { int n,j,a,maxn,maxp; int prime

进击的大角虫 1956

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

HDU 2710 Max Factor(素数筛选)

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2710 题目大意:给出几个数,找出最大的素数因子,如果素数因子相同,则输出最小的那个数。 思路:以前求素数都是用两层循环,现在这个数字比较大,还是用老方法会超时,所以很容易想到素数筛选(以前就做过一道素数筛选的题目,嘿嘿),题目唯一不同的就是在题目里面1是作为素数的(还是从网上找到的)。 代码:

A_Eagle的专栏 2652

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

hdu 2710 Max Factor 筛法

hdu 2710 Max Factor 筛法 To improve the organization of his farm, Farmer John labels each of his N (1 <= N <= 5,000) cows with a distinct serial number in the range 1..20,000. Unfortunately, he is unaware that the cows interpret some serial numbers as better

klc的博客 404

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

HDU 2710 Max Factor

链接:http://acm.hdu.edu.cn/showproblem.php?pid=2710   这道题有点问题,,,是多组数据,

M阳光的专栏 1885

hdu 2710【Max Factor】

Problem Description To improve the organization of his farm, Farmer John labels each of his N (1 &lt;= N &lt;= 5,000) cows with a distinct serial number in the range 1..20,000. Unfortunately, ...

resurrectioncancel的博客 186

HDU 2710.Max Factor

题目:http://acm.hdu.edu.cn/showproblem.php?pid=2710 AC代码(C++): #include #include #include #include #include #include #include #define INF 0x3f3f3f3f #define eps 1e-8 typedef unsigned lon

njyexiong的博客 262

[HDU - 2710] Max Factor

Problem Description To improve the organization of his farm, Farmer John labels each of his N (1 &lt;= N &lt;= 5,000) cows with a distinct serial number in the range 1..20,000. Unfortunately, he is u...

Chanx 's Blog 261

Max Factor hdu2710

Problem Description To improve the organization of his farm, Farmer John labels each of his N (1 <= N <= 5,000) cows with a distinct serial number in the range 1..20,000. Unfortunately, he is unawa

chaoyueziji123的专栏 707

HDU2710 Max Factor

Description To improve the organization of his farm, Farmer John labels each of his N (1 <= N <= 5,000) cows with a distinct serial number in the range 1..20,000. Unfortunately, he is unaware that

xu_fish的博客 653

Max Factor hdu2710 素数相关

http://acm.hdu.edu.cn/showproblem.php?pid=2710 按最大质因数排序,输出含有最大质因数的数。 比较简单的问题啦。 =w= #include #include #include using namespace std; #define N 20005 int factor[N]; void init(){ int k=floor(sqrt(

operator456的专栏 514

hdu 2710 Max Factor

hdu 2710 Max FactorProblem Description To improve the organization of his farm, Farmer John labels each of his N (1 <= N <= 5,000) cows with a distinct serial number in the range 1..20,000. Unfortu

HJ 592

HDU2710:Max Factor

Problem Description To improve the organization of his farm, Farmer John labels each of his N (1 <= N <= 5,000) cows with a distinct serial number in the range 1..20,000. Unfortunately, he is unaware

ACM!荣耀之路! 1928
上一篇: 第五届蓝桥杯C/C++程序设计B组省赛第四题
下一篇: 第五届蓝桥杯C/C++程序设计B组省赛第五题
tjial
博客等级 码龄9年 26粉丝 149原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值