首页 > 其他 > 详细

Hdu 1029 Ignatius and the Princess IV

时间:2018-05-20 10:20:06      阅读:187      评论:0      收藏:0      [点我收藏+]

思路:普通的cin会超时 方法很妙

 1 #include<iostream>
 2 #include<algorithm>
 3 #include<string>
 4 #include<cstring>
 5 #include<cmath>
 6 using namespace std;
 7 int main()
 8 {
 9     std::ios::sync_with_stdio(false);
10     int n;
11     while(cin>>n){
12         int x,num,t=0;
13         for(int i=0;i<n;i++){
14             cin>>x;
15             if(t==0){
16                 t=1;
17                 num=x;
18             }
19             else{
20                 if(x==num) t++;
21                 else t--;
22             }
23         }
24         cout<<num<<endl;
25     }
26     return 0;
27 }

 

Hdu 1029 Ignatius and the Princess IV

原文:https://www.cnblogs.com/shixinzei/p/9062302.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!