Bzoj3400: [usaco 2009 Mar] cow frisbee team sandbox team

Source: Internet
Author: User
3400: [usaco 2009 Mar] cow frisbee team time limit: 3 sec memory limit: 128 MB
Submit: 89 solved: 60
[Submit] [Status] Description after the farmer started playing frisbee, John also planned to make the cows enjoy the Frisbee. he wants to build a cow frisbee team. his n (1 ≤ n ≤ 2000) cows, each having a Frisbee level index RI (1 ≤ rI ≤ 100000 ). john wants to select one or more cows to join his Frisbee. john's lucky number is F (1 ≤ F ≤ 1000), and he wants the sum of the flat level indexes of all cows to be a multiple of the lucky numbers. to help John calculate the total number of teams. input 1st rows input N and F, followed by N rows input Ri. result of the output team-up mode: 10 ^ 8. sample input4 5
1
2
8
2 Sample output3hint

 

There are three teaming methods: (2, 3), (3, 4), (1, 2, 4)

 

Source

Silver

Question: It's similar to a backpack. scroll down. Code:
 1 #include<cstdio> 2 #include<cstdlib> 3 #include<cmath> 4 #include<cstring> 5 #include<algorithm> 6 #include<iostream> 7 #include<vector> 8 #include<map> 9 #include<set>10 #include<queue>11 #include<string>12 #define inf 100000000013 #define maxn 120014 #define maxm 500+10015 #define eps 1e-1016 #define ll long long17 #define pa pair<int,int>18 #define for0(i,n) for(int i=0;i<=(n);i++)19 #define for1(i,n) for(int i=1;i<=(n);i++)20 #define for2(i,x,y) for(int i=(x);i<=(y);i++)21 #define for3(i,x,y) for(int i=(x);i>=(y);i--)22 #define mod 10000000023 using namespace std;24 inline int read()25 {26     int x=0,f=1;char ch=getchar();27     while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}28     while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();}29     return x*f;30 }31 int n,m,t,f[maxn][maxn];32 int main()33 {34     freopen("input.txt","r",stdin);35     freopen("output.txt","w",stdout);36     n=read();m=read();37     f[0][0]=1;38     for1(i,n)39     {40         int x=read()%m;41         t=1-t;42         for0(j,m-1)f[t][j]=(f[1-t][j]+f[1-t][(j-x+m)%m])%mod;43     }44     printf("%d\n",f[t][0]-1);45     return 0;46 }
View code

 

Bzoj3400: [usaco 2009 Mar] cow frisbee team sandbox team

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.