NOJ1184 Lost stamp Hash list

Source: Internet
Author: User

Test instructions

A total of n stamps were collected, and now 2 were lost, leaving N-2 Zhang ... the stamps originally collected were all collected in pairs, so the two types of stamps were found to be single and output. (Make sure the missing stamps are not the same)

Ideas

Because the number is larger, you can use the hash table to compress the size of the group can be opened. Compression is just as good as taking the mold. If the conflict goes to the next look.

Code
#include <cstdio>#include <cstring>#define MOD 1000007Const intMAXN =1000010;structNode {intCntintNum;}; Node S[MAXN];intMain () {intNscanf("%d", &n); for(inti =0; I < n2; i + +) {intAscanf("%d", &a);//????        intAhash = A%mod; while(S[ahash].num! = a && S[ahash].num! =0) {Ahash + +;        Ahash = AHASH%MAXN;        } s[ahash].num = A;    S[ahash].cnt + +; }BOOLFirst =true; for(inti =0; i < MAXN; i + +) {if(s[i].cnt%2) {if(first) {first =false;printf("%d", S[i].num); }Else printf("%d\n", S[i].num); }    }return 0;}

NOJ1184 Lost stamp Hash list

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.