Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
超时,哭#include <iostream> using namespace std; struct abc{ int a,c; }que[101]; int main() { int t,m; int r; int i,j,k; int tem[10000]; int temp; int count; int p; while(1) { scanf("%d%d",&t,&m); if(t==0 && m==0) break; short judge[100001]={0}; for(i=0;i<t;i++) { scanf("%d",&que[i].a); } for(i=0;i<t;i++) { scanf("%d",&que[i].c); } tem[0]=0; r=1; count=0; for(i=0;i<t;i++) { p=r; for(j=1;j<=que[i].c;j++) { for(k=0;k<r;k++) { temp=j*que[i].a+tem[k]; if(temp<=m && judge[temp]==0) { judge[temp]=1; ++count; tem[p]=temp; ++p; } } } r=p; } cout<<count<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator