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

我的数据好像都通的过,但就是ac不了,请各位帮我看看,谢了

Posted by plan288 at 2007-01-03 12:29:47 on Problem 1001
#include<stdio.h>
#define N 130
#define M 6
#define H 15
char insert[M][N];
int insert1[M];
double in1[M];
int hb[M];
int Min(int a,int b){
     if(a>b) return b;
     else return a;
     }
void Add(char *Number1,char *Number2){
     int c=0;
     int i;
     for(i=0;i<N;i++){
             if(i>0){             
             if(Number1[i-1]>=10){
             c=1;
             Number1[i-1]=Number1[i-1]-10;
                                  }
             else c=0;
             }
             Number1[i]=Number1[i]+Number2[i]+c;
             }
             }
             
void Move(char *Number){
     int flag=0;
     int i;
     for(i=N-1;i>0;i--){
             if(Number[i-1]) flag=1;
             if((!Number[i])&&(!flag))
             continue;
             Number[i]=Number[i-1];
             }
             Number[0]=0;
             }
             
char *S_Mul(char *Number,char k){
     char c=0;
     int i;
     int j;
     static char array[N];
     for(i=0;i<N;i++)
     array[i]=0;        
     if((k>=10)&&(k<0))
     return array;
     for(j=0;j<k;j++)
     Add(array,Number); 
     return array;      
}
                 
void Mul(char *Number1,char *Number2){
     char *pt;
     char Mid[N];
     int i;
     for(i=0;i<N;i++)
     Mid[i]=0;
     for(i=0;i<N;i++){
             pt=S_Mul(Number1,Number2[i]);
             for(int j=0;j<i;j++)
             Move(pt);
             Add(Mid,pt);
             }
     for(i=0;i<N;i++)
     Number1[i]=Mid[i];
     }
     
void _Power(char *Number,int k){
     char bi[N];
     int i;
     for(i=0;i<N;i++)
     bi[i]=Number[i];
     if(k>1)
     for(i=1;i<k;i++)
     Mul(Number,bi);
     }

void _In(){
     double in[M];
     long long k;
     int i;
     int j;
     for(i=0;i<M;i++){
             scanf("%lf%d",&in1[i],&insert1[i]);
             in[i]=in1[i];
             for(j=0;j<H+1;j++){
                     if((int)(in[i]/10000)){
                                    hb[i]=j;
                                    break;
                                    }
                     else
                     in[i]=in[i]*10;
                     }
             k=(long long)in[i];        
             for(j=0;j<H+1;j++){
                     insert[i][j]=k%10;
                     k=k/10;
                     }
             }
             }

void _Print(){
     int  k;
     int down[M];
     int up[M];
     int i;
     int j;
     for(i=0;i<M;i++){
             if(in1[i]<1){
                          for(j=0;j<N;j++){
                                  if(insert[i][j]){
                                                   down[i]=j;
                                                   break;
                                                   }
                          }
                          }
             else {
                  for(j=0;j<N;j++){
                         if(insert[i][j]){
                                          down[i]=j;
                                          break;
                                          }
                                          }
                  for(j=N-1;j>=0;j--){
                          if(insert[i][j]){
                                           up[i]=j;
                                           break;
                                           }
                                           }
                  }
                  }                                                              
     for(i=0;i<M;i++){
             if(in1[i]<1){
                          printf(".");
                          for(int j=hb[i]*insert1[i]-1;j>=down[i];j--)
                          printf("%d",insert[i][j]);
                          printf("\n");
                          }
             else {
                  for(j=up[i];j>=Min(down[i],(hb[i]*insert1[i]));j--){
                          if(j==hb[i]*insert1[i]-1)
                          if(Min(down[i],(hb[i]*insert1[i]))!=(hb[i]*insert1[i]))
                          printf(".");
                          printf("%d",insert[i][j]);
                          }
                          printf("\n");
                          }
                          }
                          }
int main(){
    _In();
    int a;
    for(a=0;a<M;a++)
    _Power(insert[a],insert1[a]);
    _Print();
    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