The eighth annual Blue Bridge Cup provincial C + + Group A 8th Bun Dine

Source: Internet
Author: User
Tags gcd

Tagged with: using div i++ SDN ref space thinking C + + number theory

Reference to the http://blog.csdn.net/y1196645376/article/details/69718192

Ideas:

Number theory + full backpack.

Realize:

1#include <iostream>2#include <cstdio>3 using namespacestd;4 5 Const intMAXN =100005;6 7 inta[ the], OK[MAXN], N;8 9 intgcdintXinty)Ten { One     return!y? X:GCD (y, x%y); A } -  - intMain () the { -CIN >>N; -      for(inti =0; I < n; i++) -     { +CIN >>A[i]; -     } +     intg = a[0]; A      for(inti =1; I < n; i++) at     { -g =gcd (g, a[i]); -     } -     if(g! =1) -Puts"INF"); -     Else in     { -ok[0] =true; to          for(inti =0; I < n; i++) +         { -              for(intj =0; J + A[i] < MAXN; J + +) the             { *                 if(Ok[j]) $                 {Panax NotoginsengOk[j + a[i]] =true; -                 } the             } +         } A         intCNT =0; the          for(inti =0; i < MAXN; i++) +         { -             if(!Ok[i]) $cnt++; $         } -printf"%d\n", CNT); -     } the     return 0; -}

The eighth annual Blue Bridge Cup provincial C + + Group A 8th Bun Dine

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.