精品偷拍一区二区三区,亚洲精品永久 码,亚洲综合日韩精品欧美国产,亚洲国产日韩a在线亚洲

  • <center id="usuqs"></center>
  • 
    
  • ACM HDU 1029 Ignatius and the Princess IV(JAVA)

    ACM HDU 1029 Ignatius and the Princess IV(JAVA)
    import java.util.Scanner;
    public class Main {
    public static void main(String args[]) {
    Scanner ss = new Scanner(System.in);
    long n, num, cnt, res = 0;
    n = ss.nextLong();
    while (true) {
    if (!ss.hasNext()) break;
    cnt = 0;
    while (n!=0) {
    n--;
    num = ss.nextLong();
    if (0 == cnt) {
    res = num;
    cnt++;
    } else {
    if (res == num)
    cnt++;
    else
    cnt--;
    }
    }
    System.out.println(res);
    n = ss.nextLong();
    }
    }
    }
    為什么總是WA.
    其他人氣:383 ℃時間:2020-06-28 18:46:46
    優(yōu)質(zhì)解答
    是讀取的問題. 最后一組數(shù)據(jù)沒有被處理
    import java.util.Scanner;
    public class Main {
    public static void main(String args[]) {
    Scanner ss = new Scanner(System.in);
    long n, num, cnt, res = 0;
    while(ss.hasNextLong())
    {
    n = ss.nextLong();
    cnt = 0;
    while (n!=0) {
    n--;
    num = ss.nextLong();
    if (0 == cnt) {
    res = num;
    cnt++;
    } else {
    if (res == num)
    cnt++;
    else
    cnt--;
    }
    }
    System.out.println(res);
    }
    }
    }
    我來回答
    類似推薦
    請使用1024x768 IE6.0或更高版本瀏覽器瀏覽本站點,以保證最佳閱讀效果。本頁提供作業(yè)小助手,一起搜作業(yè)以及作業(yè)好幫手最新版!
    版權(quán)所有 CopyRight © 2012-2024 作業(yè)小助手 All Rights Reserved. 手機(jī)版