首页 > 其他分享 >poj 1837

poj 1837

时间:2023-08-23 10:01:42浏览次数:41  
标签:std main 1837 int 50 poj include


http://poj.org/problem?id=1837

#include<stdio.h>
 #include<stdlib.h>
 #include<string.h>
 #include<math.h>
 #include<iostream>
 #include<algorithm>
 using namespace std;


 int dp[21][15001];


 int main()
 {
     int n,m;
     int c[50];
     int g[50];
     int i,k,j;
     while(scanf("%d%d",&n,&m)!=EOF)
     {
         for(i=1;i<=n;i++)
             scanf("%d",&c[i]);
         for(j=1;j<=m;j++)
             scanf("%d",&g[j]);
         memset(dp,0,sizeof(dp));
         dp[0][7500]=1;
         for(i=1;i<=m;i++)
             for(k=0;k<=15000;k++)
             {
                 if(dp[i-1][k])
                     for(j=1;j<=n;j++)
                         dp[i][k+g[i]*c[j]]+=dp[i-1][k];
             }
         printf("%d\n",dp[m][7500]);
     }
     return 0;
 }

标签:std,main,1837,int,50,poj,include
From: https://blog.51cto.com/u_16234093/7199349

相关文章

  • 我的poj 计划
    写了好久代码,偶然间我放弃了,长时间下来,感觉一切都是好空啊。无所事事,想一个傻子似的。我应该回到自己的代码时代,虽然我曾经放弃,但现在的我会像一个新手慢慢开始自己的代码之旅。初学者题:;100110371048104910511067;模拟问题:;100610091012101610191023;动态规划:;101310221025102710741076......
  • 北大ACM poj3979 分数加减法
    分数加减法TimeLimit:1000MS MemoryLimit:65536KTotalSubmissions:10041 Accepted:3241Description编写一个C程序,实现两个分数的加减法Input输入包含多行数据每行数据是一个字符串,格式是"a/boc/d"。其中a,b,c,d是一个0-9的整数。o是运算符"+......
  • 北大ACM poj3589 Number-guessing Game
    Number-guessingGameTimeLimit:1000MS MemoryLimit:65536KTotalSubmissions:5805 Accepted:4204DescriptionLarrylikesplayingthenumber-guessinggame.Twoplayersareneededinagame.SupposetheyareXandY,andXpresentsanumberforYtogu......
  • 北大ACM poj3913 Gnome Sequencing
    GnomeSequencingTimeLimit:1000MS MemoryLimit:65536KTotalSubmissions:1267 Accepted:865DescriptionInthebookAllCreaturesofMythology,gnomesarekind,beardedcreatures,whilegoblinstendtobebossyandsimple-minded.Thegoblinslike......
  • 北大ACM poj3994 Probability One
    ProbabilityOneTimeLimit:1000MS MemoryLimit:65536KTotalSubmissions:938 Accepted:660DescriptionNumberguessingisapopulargamebetweenelementary-schoolkids.Teachersencouragepupilstoplaythegameasitenhancestheirarithmeticski......
  • 北大ACM poj3750 小孩报数问题
    小孩报数问题TimeLimit:1000MS MemoryLimit:65536KTotalSubmissions:7233 Accepted:3454Description有N个小孩围成一圈,给他们从1开始依次编号,现指定从第W个开始报数,报到第S个时,该小孩出列,然后从下一个小孩开始报数,仍是报到S个出列,如此重复下去,直到所有的小孩都......
  • 北大ACM poj1002 487-3279
    487-3279TimeLimit:2000MS MemoryLimit:65536KTotalSubmissions:191845 Accepted:33280DescriptionBusinessesliketohavememorabletelephonenumbers.Onewaytomakeatelephonenumbermemorableistohaveitspellamemorablewordorphrase.......
  • 北大ACM poj1661 Help Jimmy
    HelpJimmyTimeLimit:1000MS MemoryLimit:10000KTotalSubmissions:7380 Accepted:2333Description"HelpJimmy"是在下图所示的场景上完成的游戏。场景中包括多个长度和高度各不相同的平台。地面是最低的平台,高度为零,长度无限。Jimmy老鼠在时刻0从高......
  • 北大ACM poj1050 To the Max(C++)
    TotheMaxTimeLimit:1000MS MemoryLimit:10000KTotalSubmissions:32446 Accepted:16930DescriptionGivenatwo-dimensionalarrayofpositiveandnegativeintegers,asub-rectangleisanycontiguoussub-arrayofsize1*1orgreaterlocatedwithi......
  • 北大ACM poj2141 Message Decowding
    MessageDecowdingTimeLimit:1000MS MemoryLimit:65536KTotalSubmissions:10326 Accepted:5672DescriptionThecowsarethrilledbecausethey'vejustlearnedaboutencryptingmessages.Theythinktheywillbeabletousesecretmessagestoplot......