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

Re:谁能多给点数据测试啊,我写了一个晚上的代码,却不能ac(附代码和几个得到的数据)

Posted by fangyixiang at 2008-07-21 11:54:18 on Problem 1001
In Reply To:谁能多给点数据测试啊,我写了一个晚上的代码,却不能ac(附代码和几个得到的数据) Posted by:leevickwan at 2006-08-28 23:40:24
> 99.999 25
> 99975002999770012649468717709519310815545705768715.42652002479974457367312604296
> 4184298069822900531298735002299997000002499999
> 0.0001 25
> .0000000000000000000000000000000000000000000000000000000000000000000000000000000
> 000000000000000000001
> 
> 
> #include<iostream>
> using namespace std;
> 
> int result[126];
> int factor[6];
> int temp[126];
> int arr[126];
> 
> 
> void mul(int result[],int b)
> {
>      int i=0;
>      for(i=0;i<126;i++)
>                        arr[i]=0;
>      int carry=0;
>      int k=0;
>      for(i=0;i<126;i++)
>      {                 
>                        k=carry+result[i]*b;
>                        arr[i]=k%10;
>                        carry=k/10;                 
>      }
>      
> 
> }
> 
> 
> void add(int temp[],int arr[],int index)
> {
>      int carry=0;
>      int i=0;
>      int k=0;
>      for(i=0;i<126;i++)
>      {
>                        k=temp[i+index]+arr[i]+carry;
>                        temp[i+index]=k%10;
>                        carry=k/10;
>                        }
>                        
>          
>      }
>      
> //
> void mul(int result[],int factor[])
> {
>     
>      int i=0;
>      for(i=0;i<126;i++)
>                        temp[i]=0;
>      for(i=0;i<5;i++)
>      {
>                      mul(result,factor[i]);  
>                      add(temp,arr,i);
>                      }
>      
>      for(i=0;i<126;i++)
>       result[i]=temp[i];
>      }
>      
>      
> int main(void)
> {
>     char in[7];;
>     int n=0;
>     while(cin>>in>>n)
>    {
>     
>     int point=0;
>     if(in[1]=='.')
>                   point=1;
>     else
>         point=2;
>     int num=0;
>     while(in[7-num]=='0')
>                          num++;
>     
>     int numofpoint=(5-point-num)*n;
>    
>    
>                   
>     int i=0;
>     for(i=0;i<126;i++)
>     {
>                       result[i]=0;
>                       temp[i]=0;
>                       arr[i]=0;
>                       }  
>                        
>     for(i=5;i>=3;i--)
>     {
>                         factor[5-i]=in[i]-48;//0,1,2
>                          result[5-i]=in[i]-48;
>     }
>     
>    factor[4]=in[0]-48;
>    result[4]=in[0]-48;
>    
>    if(point==1)
>    {
>    factor[3]=in[2]-48;
>    result[3]=in[2]-48;
>                }
>    else
>    {
>        factor[3]=in[1]-48;
>        result[3]=in[1]-48;
>        }
>       
>     for(i=0;i<n-1;i++)
>     {
>                       mul(result,factor);
>     }
>     
>     int end=0;
>     while(result[125-end]==0)
>                                end++;
>     int start=0;
>     while(result[start]==0) 
>                           {  start++;  
>                              if(start==numofpoint)
>                              break;
>                            }                
>     int k=start;
>     if(in[5]!='0')
>                   start=0;
>    
>    if(125-end>=numofpoint)
>     for(i=125-end;i>=start;i--)
>      {                        
>                             cout<<result[i];
>                            if(i==numofpoint&&i!=start-1)
>                             cout<<'.';
>                             
>                             }
> else
> {
>     cout<<'.';
>     
>  for(i=numofpoint-1;i>=start;i--)                      
>                             cout<<result[i];  
>                             }                
>    cout<<endl;
>    
> }
>    //system("pause");
>     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