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