HDU-1029 java

hpm6750evk2开发板(四)TCP回送(1000M网口) 再接下来我们修改代码,先找到配置网速的地方,肯定是在enet的初始化函数里面,我们一个函数一个函数找,也可以用单步调试一步一步找,结果发现是在enet_init函数里面调用的rtl8211_basic_mode_default_config函数配置网速的,我们把enet_phy_port_speed_100mbps改为enet_phy_port_speed_1000mbps,重新编译运行试试。首先我们复制一份lwip_tcpecho代码,重命名为lwip_tcpecho_RGMII,如下图所示。 阅读详情

Ignatius and the Princess IV

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others)
Total Submission(s): 39731    Accepted Submission(s): 17315


Problem Description
"OK, you are not too bad, em... But you can never pass the next test." feng5166 says.

"I will tell you an odd number N, and then N integers. There will be a special integer among them, you have to tell me which integer is the special one after I tell you all the integers." feng5166 says.

"But what is the characteristic of the special integer?" Ignatius asks.

"The integer will appear at least (N+1)/2 times. If you can't find the right integer, I will kill the Princess, and you will be my dinner, too. Hahahaha....." feng5166 says.

Can you find the special integer for Ignatius?
 

Input
The input contains several test cases. Each test case contains two lines. The first line consists of an odd integer N(1<=N<=999999) which indicate the number of the integers feng5166 will tell our hero. The second line contains the N integers. The input is terminated by the end of file.
 

Output
For each test case, you have to output only one line which contains the special number you have found.
 

Sample Input
51 3 2 3 3111 1 1 1 1 5 5 5 5 5 571 1 1 1 1 1 1
 
Sample Output

351


此题java貌似过不了(说不定那种BufferedReader的读取方法可以过???没试过),下面贴上复杂度n的摩尔投票代码

import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO 自动生成的方法存根
     Scanner cin=new Scanner(System.in);
     while(cin.hasNext())
     {
    	 int N=cin.nextInt();
    	 int x;
    	 int maxnum=-1;
    	 int count=0;
    	 for(int i=0;i<N;i++)
    	 {
    		 x=cin.nextInt();
    		 if(count==0)
    		 {
    			 maxnum=x;
    			 count=1;
    		 }
    		 else if(maxnum==x)
    		 {
    			 count++;
    		 }
    		 else count--;	 
    	 }
    	 System.out.println(maxnum);
    	 
     }
	}

}
摩尔投票,赠送网址一个http://mabusyao.iteye.com/blog/2223195
------------------------------------------------------------------------------------------
今天闲着没事,试了试BufferedReader,又参考了别人写的别的题目的用法,没想到真的过了
贴上代码:
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) {
       try{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     
		while(true)
     {
    	 
    	 String s=br.readLine();
    	 if(s.equals(""))continue;
    	 
    	 int N=Integer.parseInt(s.trim());
    	 int x;
    	 int maxnum=-1;
    	 int count=0;
    	 String str=br.readLine().trim();
		 String strings[]=str.split(" ");
    	 for(int i=0;i<N;i++)
    	 {
             x=Integer.parseInt(strings[i]);
    		 if(count==0)
    		 {
    			 maxnum=x;
    			 count=1;
    		 }
    		 else if(maxnum==x)
    		 {
    			 count++;
    		 }
    		 else count--;	 
    	 }
    	 System.out.println(maxnum);
    	 
     }
       }catch(Exception e){
    	   
       }
	}

}


UE5实现建筑剖切效果 阅读详情

相关推荐

SAP PP模块 MRP配置实战:5步完成工厂级物料需求计划激活

本文详细介绍了SAP PP模块中物料需求计划(MRP)的工厂级配置实战,通过5个关键步骤从基础环境准备到最终激活。内容涵盖SPRO后台配置、MRP控制者定义、主数据设置及核心参数调整,帮助顾问快速掌握MRP配置清单的完整流程,确保物料需求计划的高效运行。

weixin_30431445的博客 354

hdu 1029

hdu 1029

Bleach_kids的专栏 463

高斯泼溅(Gaussian Splatting):3D建模的颠覆性革命

高斯泼溅(Gaussian Splatting):3D建模的颠覆性革命

yingtu666的博客 5200

Ignatius and the Princess IV

"OK, you are not too bad, em... But you can never pass the next test." feng5166 says. "I will tell you an odd number N, and then N integers. There will be a special integer among them, you have to ...

ujn20161222的博客 226

RC模型车多电机驱动方案:从电调PWM原理到四电机安全连接实战

在电机控制领域,PWM(脉冲宽度调制)是实现精确调速的核心技术。其原理是通过调节固定周期内高电平的脉宽来编码控制指令,进而驱动电子调速器(电调)改变输出功率。这项技术对于需要多电机协同工作的场景,如RC模型车的差速转向或重型负载驱动,具有关键价值。它能实现动力的精细分配与同步,提升车辆的可控性与通过性。在实际应用中,为确保系统稳定,必须关注电流分配与信号同步问题。例如,通过为每个电机配备独立电调并采用信号并联(Y线)的方式,可以构建可靠的四电机驱动系统。这种方案能有效避免因单个电调过载或电机反电动势不一致导

weixin_30664615的博客 389

【MATLAB代码】TDOA+TOA融合算法,高精度定位。通过多边定位解算4个锚点、平面目标的位置,附代码

二维平面下的TOA、TDOA及混合定位算法,通过4个锚节点对目标点进行定位。

985工科博士毕业,专攻定位、导航和滤波等算法研究。从业10年,主要使用MATLAB 218

hdoj1029

Ignatius and the Princess IVTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others)Total Submission(s): 5220    Accepted Submission(s): 1684Problem Description"OK, you are not too bad, em... But you can never pass the next test.

独行闹市无人问,青灯剑影响素琴 780

RK3576 USB3.0 DWC3控制器调试:PHY初始化失败排查指南

DWC3 是 Synopsys 公司推出的 USB3.0/3.1 控制器 IP,支持双角色(DRD)模式,可配置为 Host、Device 或 OTG。

小灰灰的博客 1196

HDOJ 2090

Problem Description 妈妈每天都要出去买菜,但是回来后,兜里的钱也懒得数一数,到底花了多少钱真是一笔糊涂帐。现在好了,作为好儿子(女儿)的你可以给她用程序算一下了,呵呵。     Input 输入含有一些数据组,每组数据包括菜种(字串),数量(计量单位不论,一律为double型数)和单价(double型数,表示人民币元数),因此,每组数据的菜价就是数量乘上单价啊。菜种、...

weixin_34008784的博客 1225

SAP S/4 HANA CO 成本模块实战指南

摘要:SAP S/4HANA CO(管理会计)模块是企业内部成本管理的核心工具。本文系统介绍了CO模块的组织结构(控制范围与会计科目表映射)、基础概念(计划值与预算值)以及6大子模块功能(成本要素、成本中心会计等)。重点解析了各子模块的应用场景与差异,包括成本归集、费用分摊、利润分析和产品成本控制,并对比了利润中心与成本中心、内部订单与销售订单的区别。通过事务代码示例和功能对比表,帮助用户快速掌握SAP CO模块的核心管理逻辑与实施要点。

金牌架构师 1137

一文看懂 SAP Integration Suite:从架构治理、接口编排到事件驱动的集成全景

SAP Integration Suite是企业数字化转型中的关键集成平台,通过统一的方法论和工具链解决系统互联、数据对齐和流程协同等复杂问题。其核心能力包括:1)集成评估(Integration Assessment)提供战略规划框架;2)迁移评估(Migration Assessment)支持从传统平台向云的平滑过渡;3)云集成(Cloud Integration)实现日常业务流程编排;4)集成顾问(Integration Advisor)简化B2B标准映射;5)贸易伙伴管理(TPM)优化外部协作流程;

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 517

HDU-1029-Ignatius and the Princess IV(dp)

                                 Ignatius and the Princess IV   Problem Description "OK, you are not too bad, em... But you can never pass the next test." feng5166 says. "I will tell you an odd num...

1374

LeRobot 入门教程(一)软件环境、部署流程及摄像头配置

🤖 LeRobot:开源机器人学习平台 摘要:LeRobot是一个基于PyTorch的开源机器人学习平台,提供模型、数据集和工具,旨在降低机器人技术门槛。平台包含经过验证的模仿学习和强化学习方法,并提供预训练模型、人类演示数据集及模拟环境。安装需从源码获取,支持Python 3.10环境,可选扩展包括仿真环境(如gym-aloha)、电机控制(Dynamixel/Feetech SDK)和实验跟踪(Weights & Biases)。该平台托管在HuggingFace,并设有社区Discord频道

2506_90492529的博客 3436

HDU1029java版本

Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K (Java/Others) Total Submission(s): 30701 Accepted Submission(s): 13105Problem Description “OK, y

周孟齐的博客 338

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

HDOJ1029 Ignatius and the Princess IV

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1029 这个题目有个坑的地方就是,java难以AC。 使用快排或者统计都超时了,但是同样的方法使用C语言就过了。 题意是给你n个数(n是奇数),将出现次数大于(n+1)/2的数输出。 这样的数显然就只有一个的,可以使用统计的方式。 #include #include in

BarryLee的博客 363

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

HDU - 1029 Ignatius and the Princess IV (Java - map)

Ignatius and the Princess IV 借此机会,学习了一下java中的map类 import java.util.*; import java.math.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner cin = new Sc...

辞树 202

Java快速输入输出

需要的头文件有 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StreamTokenizer; 在主...

Change the world by program. 2684

hdu-1029 Ignatius and the Princess IV

hdu-1029 Ignatius and the Princess IV题目描述 Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others)Total Submission(s): 28646    Accepted S

oYinGui1 1336

HDU 1029 Ignatius and the Princess IV【DP思路】

Ignatius and the Princess IVTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others)Total Submission(s): 40942    Accepted Submission(s): 17900Problem Description "OK, you a...

Emiya丶的博客 253

[HDU - 1029] Ignatius and the Princess IV(动态规划)

Link:http://acm.hdu.edu.cn/showproblem.php?pid=1029Problem Description"OK, you are not too bad, em... But you can never pass the next test." feng5166 says."I will tell you an odd number N, and then N i

Hello Joanna 326

HDU1029

import java.util.Map.Entry; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String args[]) {

Loser_LOSERdyh的博客 141

HDU 1029 Ignatius and the Princess IV (简单DP)

hdu 1029 题目: Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others) Total Submission(s): 42940    Accepted Submission(s): 18774   Problem ...

Kruskal的博客 403

HDU1029 Ignatius and the Princess IV(数组中出现次数最多的数)

题目:HDU1029 Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32767 K (Java/Others) Total Submission(s): 44112Accepted Submission(s): 19470 Problem De...

CarreLiu 198

HDU1029 Ignatius and the Princess IV【排序】

Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others) Total Submission(s): 37147    Accepted Submission(s): 16227 Problem Description

海岛Blog 2308

大数计算方法

大数计算三种方法: 一.c/c++模拟法   二.c/c++万进制/亿进制法 1.UVA495 Fibonacci Freeze【大数 万进制】   三.采用Java/Python来写(代码简洁,强烈推荐) 1.51NOD-1027 大数乘法【大数 Python、Java】 2.51NOD-1028 大数乘法V2【大数 Python、Java】 3.51NOD-1029 大数除法...

fyy_lufan的博客 4249

HDU 1029

Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others) Total Submission(s): 35692    Accepted Submission(s): 15574 Problem Descriptio

yane的博客 360

hdu1029

Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K (Java/Others) Problem Description "OK, you are not too bad, em... But you can never pass the ne

代码艺术的道与术 776
上一篇: HDU-1024 java 实现
下一篇: HDU-1069-java实现
SoulGuide
博客等级 码龄9年 9粉丝 14原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址