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

Who can tell me why it is wrong answer? Thank you!

Posted by Ray_xiang at 2005-10-17 19:54:55 on Problem 2673
#include<stdio.h>
#include<math.h>


int zjh[1000][2];
int main()
{
    int t,x,m,a,i;
    int hh=0;
    double temp=10000000;

    scanf("%d%d%d",&t,&x,&m);

    
    for(i=0;i<m;i++){
        scanf("%d%d",&zjh[i][0],&zjh[i][1]);
        if((double)(zjh[i][0])/zjh[i][1]<temp) { temp=(double)(zjh[i][0])/zjh[i][1];a=i;}
    }

    if(temp<1||fabs(temp-1)<1e-10) { printf("0\n");return 0;}
    if(temp>t||m==0) printf("%d\n",t*x);
    
    else {

            if(zjh[a][0]%zjh[a][1]==0) {
                hh+=(zjh[a][0]/zjh[a][1]-1)*x;
                t-=zjh[a][0]/zjh[a][1]-1;
                while(t>1){
                    hh+=x;
                    t-=2;
                }
            }
            
            else {
                hh+=(zjh[a][0]/zjh[a][1])*x;
                t-=zjh[a][0]/zjh[a][1];
                while(t>1){
                    hh+=x;
                    t-=2;
                }
            }
            
        }
        
        printf("%d\n",hh);
        
        
        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