BestCoder24 1001.Sum sum sum (hdu 5150) Problem Solving report

Source: Internet
Author: User

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5150

The meaning of the topic is directly seeking prime numbers.

But n = 1, also belongs to the answer range!! Can only say, ever a knave ah ~~~~~

  

1#include <iostream>2#include <cstdio>3#include <cstdlib>4#include <cstring>5 using namespacestd;6 7 Const intMAXN = ++5;8 intPRIME[MAXN];9 Ten BOOLIs_prime (intx) One {   A //if (x = = 1)//too many hands, no preconceived. - //return false; //the culprit who was hack. -     if(x = =2) the         return true; -      for(inti =2; I * I <= x; i++) -     { -         if(x% i = =0) +             return false; -     } +     return true; A } at  - intMain () - { -memset (Prime,0,sizeof(prime)); -      for(inti =1; I <= MAXN; i++) -     { in         if(Is_prime (i)) -Prime[i] =1; to     } +  -     intn, data; the      while(SCANF ("%d", &n)! =EOF) *     { $         intsum =0;Panax Notoginseng          for(inti =0; I < n; i++) -         { thescanf"%d", &data); +             if(Prime[data]) ASum + =data; the         } +printf"%d\n", sum); -     } $     return 0; $}

BestCoder24 1001.Sum sum sum (hdu 5150) Problem Solving report

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.