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

快疯了,谁救一下我!为什么当输入2,3,5时a[0]会等于0呢?

Posted by chgsh8089 at 2006-03-04 14:06:56 on Problem 2545
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    __int64 t,k,pk,t1,j,i1,n,p1,p2,p3,sum;
    __int64 a[3000];
    
    int i;
    long double p;
    pk=pow((double)10,(double)18);
    //cout<<"pk:"<<pk<<endl;
   while(cin>>p1>>p2>>p3>>i)
  {
    k=0;
    for(j=0;j<60;j++)
        for(t=0;t<60;t++)
            for(n=0;n<60;n++)
            {   p=pow((double)p1,(double)j)*pow((double)p2,(double)t)*pow((double)p3,(double)n);
                if(p<=pk)
                
                {       
                         a[k]=p;
                          
                //cout<<"a["<<k<<"]"<<a[k]<<endl;
                k++;
                }
                else break;
            }
    sort(a,a+k);cout<<a[0]<<endl
  ;//为什么当输入的p1,p2,p3为2,3,5时a[0]=0?上面的a[k]=p中p可能等于0吗??哪里错了?? 
  //  for(j=0;j<200;j++)
  //  cout<<"a["<<j<<"]"<<a[j]<<endl;
  // cin>>i;
 
    if(a[0]==0)cout<<a[i+1]<<endl;
    else cout<<a[i]<<endl;
    
 
    
}    
    
   
    
    delete[]a;
    
    return 0;
}
// 提交n次,老是运行出错~,somebody helps me~~

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