HDOJ 1029 Ignatius and the Princess IV 【math】
来源:互联网 发布:多益网络ipo结果 编辑:程序博客网 时间:2024/04/30 22:13
HDOJ 1029 Ignatius and the Princess IV 【math】
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1029
N是奇数,并且最后的special integer出现次数至少为 (N+1)/2
所以special integer出现的次数一定比其他所有数出现的总数还多
一点一点滴 耗死其他的数就可以鸟。。。
#include<cstdio>int N, num, cnt, ans;int main(){ while(~scanf("%d", &N)){ cnt = 0; while(N--){ scanf("%d", &num); if(cnt == 0){ // 刚开始或一个数已经被耗尽 开始计算新的数据 ans = num; cnt++; } else{ if(ans == num) cnt++; else cnt--; } } printf("%d\n", ans); } return 0;}
0 0
- HDOJ 1029 Ignatius and the Princess IV 【math】
- 【HDOJ】1029 -> Ignatius and the Princess IV
- hdoj 1029 Ignatius and the Princess IV
- HDOJ 1029 Ignatius and the Princess IV
- HDOJ Ignatius and the Princess IV 1029
- HDOJ 1029 Ignatius and the Princess IV
- hdoj 1029 Ignatius and the Princess IV
- HDOJ 1029 Ignatius and the Princess IV
- hdoj-1029-Ignatius and the Princess IV
- hdoj 1029 Ignatius and the Princess IV
- HDOJ 1029 Ignatius and the Princess IV
- HDOJ 1029 Ignatius and the Princess IV [map]
- HDOJ 1029:Ignatius and the Princess IV 解题报告
- hdoj.1029 Ignatius and the Princess IV 20140809
- hdoj 1029 Ignatius and the Princess IV 【简单】
- HDOJ 1029 Ignatius and the Princess IV (水题)
- HDOJ 1029 Ignatius and the Princess IV(易题)
- 杭电HDOJ 1029 Ignatius and the Princess IV
- DHTMLX中,通过For循环,将JSON值以tree的形式展示
- hadoop 编程规范(hadoop专利分析)
- Palindrome
- crontab 定时任务
- 线性表的顺序存储结构(顺序表)
- HDOJ 1029 Ignatius and the Princess IV 【math】
- scanf的深究与清除缓冲区的那些方法
- android LayoutInflate.inflate源码分析及使用区分
- word2vec代码注释
- JAVA 基础(面向对象)
- TCP/IP协议之三(TCP连接的建立与断开)
- 杭电 1513 Palindrome(LCS)
- Serializable的实例
- 输入流&输出流经典案例