Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

超时,哭

Posted by xiaol at 2005-10-15 11:52:33 on Problem 1742
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator