HDU1029(KB12-B)】的更多相关文章

题意:是用两个指针的一个模拟时钟的时针和分针.两个指针形成一个角度.角度测量两个指针之间的最小角度.两只手之间的角度是大于或等于0,且小于或等于180度的度量.由于一个序列的五个不同的写入时间,格式为hh:mm,其中......是两个数字较完整的24小时( 00 <= ...... <= 23)和mm(00 <=毫米<= 59),你发现的中位数,也就是写一个程序,第三个元素的排序序列在两个数字代表分钟非递减顺序及其关联的角度.例如,假设您将得到一个序列(06:05,07:10,03…
#include<iostream>#include<string.h>using namespace std;int main(){ int n,i; int t; int cnt; int result; while(scanf("%d",&n)!=EOF) { cnt=0; for(i=0;i<n;i++) { scanf("%d",&t); if(cnt==0) { cnt=1; result=t; } else…
<题目链接> 题目大意:给你一段序列,问你在这个序列中出现次数至少为 (n+1)/2 的数是哪个. 解题分析: 本题是一道水题,如果用map来做的话,就非常简单,但是另一个做法还比较巧妙. 解法一: #include <cstdio> int main() { int n,t,cnt,result; while(scanf("%d",&n)!=EOF){ cnt=; ;i<n;i++){ scanf("%d",&t);…
Ignatius and the Princess IV 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1029 借鉴链接:https://blog.csdn.net/tigerisland45/article/details/52146154 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others)Total Submission(s): 4…
我为什么总是犯这些愚蠢错误啊,还是自己逻辑不够严谨. 努力ing...... #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; typedef long long LL; LL x; int n; int main () { while (~scanf ("%d",&n) ) { ;…
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others)Total Submission(s): 30040    Accepted Submission(s): 12812 Problem Description "OK, you are not too bad, em... But you can never pass the…
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others)Total Submission(s): 43629    Accepted Submission(s): 19213 Problem Description "OK, you are not too bad, em... But you can never pass the…
给你n个数字,请你找出出现至少(n+1)/2次的数字. 输入 本题包含多组数据,请处理到EOF: 每组数据包含两行. 第一行一个数字N(1<=N<=999999) ,保证N为奇数. 第二行为N个用空格隔开的整数. 输出 对于每组数据,输出一行,表示要求找到的那个数 样例输入 5 1 3 2 3 3 11 1 1 1 1 1 5 5 5 5 5 5 7 1 1 1 1 1 1 1 样例输出 3 5 1 思路:第一种思路是将数组排序,由于其出现(n+1)/2   次,故中位数一定是要找的那个数.时…
"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 af…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1029 题目大意: 多组数据,每组数据先给一个n,然后给n各数字,找出n各数字中出现了至少(n+1)/2次的数字并输出(保证n为奇数) 看到这题被分类进了dp我还是有点懵逼,我不知道我这算不算dp做法. 我是用的桶排序思想, 由于数据范围如此,直接进行遍历桶是会炸时间的, 所以多开一个数组记录下出现过的数字就行. 题不难 #include<cstdio> #include<cstring>…