pat:1048. Find Coins (25) (hash table method) AC

Source: Internet
Author: User

#include<stdio.h>#include<string.h>int harsh[1066];int main () {memset (HARSH,0,sizeof (HARSH));int n,m; scanf"%d%d", &n,&m);Forint i=0; I<n; ++i) {int tmp; scanf"%d", &tmp); ++HARSH[TMP]; }Forint i=0; i<1066; ++i) {if (harsh[i]==0" //this number does not continue; if (harsh[m-i]>0) {if (i==m-i && HARSH [I]<2) //these two numbers are the same time, but only one is available, also not continue ; printf ( "%d%d" I,m-i ); //has ruled out the possibility of output, the conditions are satisfied on the output return 0;} printf ( Span class= "string" >no solution"); return 0;}          

pat:1048. Find Coins (25) (hash table method) AC

Related Article

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.