美文网首页
【洛谷】P1469 - 找筷子

【洛谷】P1469 - 找筷子

作者: 莫wen | 来源:发表于2020-11-18 09:14 被阅读0次
//效率不通过
public class Main {
    static int N ;
    static int[] arr ;
    
    static HashSet<Integer> set = new HashSet<Integer>();
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        N = sc.nextInt();
        
        arr = new int[N];
        
        for (int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        
        Arrays.sort(arr);
        
        for (int i = 0; i < N; i++) {
            if (set.contains(arr[i])) {
                set.remove(arr[i]);
            }else {
                set.add(arr[i]);
            }
            
        }
        
        for(Object o : set) {
            System.out.println(o);
        }
        
        sc.close();
            
    }

}

public class Main {
    public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int res = 0;
    for (int i = 0; i < n; i++) {
        res = res ^ s.nextInt();
    }
    System.out.println(res);
    s.close();
}}
public class Main{
    
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a[]=new int[10000001];
        int num;
        int n=sc.nextInt();
        for (int i = 0; i < n; i++) {
            num=sc.nextInt();
            a[num]++;
        }
        for (int i = 0; i < 10000001; i++) {
            if(a[i]%2==1){
                System.out.println(i);
                break;
            }
        }
        sc.close();
    }
    
    
}

相关文章

  • 【洛谷】P1469 - 找筷子

  • 洛谷计划

    洛谷是IT生认可度较高的一个网站,有各种题目以及专业术语,是刷题的一个好地方,但是对基础要求还算挺高,因此需要在...

  • 一梦青春一梦你

    接电话的时候,洛洛正在吃着火锅,她的右手还不忘夹了一筷子金针菇,“喂”“嗯”,短短两声之后,她颓然地放下筷子,蔫蔫...

  • 几个高精度模板

    模板来自洛谷及Acwing:Acwing洛谷 后续增加注释以及相关代码改进 高精度加法 高精度减法 高精度乘法 高...

  • 洛谷新手题

    今天只是做了一个简单的顺序与分支题,知识点也很常见,只截图题目和代码了~

  • P1000 超级玛丽游戏

    【题目背景】 本题是洛谷的试机题目,可以帮助了解洛谷的使用。 建议完成本题目后继续尝试P1001、P1008。 【...

  • 洛谷P1219八皇后-dfs

    题目传送:洛谷P1219八皇后 dfs

  • 信息课总结(一)

    贪心与排序 一、合并果子(洛谷ojP1090) 原题是洛谷的P1090 合并果子思路:要使总共的和最小,则要使单次...

  • 我与洛洛的日常㈠

    ㈠ 我和洛洛去餐厅吃饭,新开的一家窗口叫“五谷鱻粉”。十几种口味,应有尽有。 洛洛想吃不辣的。 于是洛洛问餐厅阿姨...

  • 好题收录

    1. 洛谷-P1980 计数问题 题目链接

网友评论

      本文标题:【洛谷】P1469 - 找筷子

      本文链接:https://www.haomeiwen.com/subject/opmqiktx.html