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 smile291779386 at 2014-03-30 17:15:47 on Problem 1131
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    char s[200];
    int sc[100],t[200];
    while(scanf("%s",s)!=EOF)
    {
      printf("%s [8] = 0.",s);
      memset(sc,0,sizeof(sc));
      int len=strlen(s),i,j;
      for(j=0,i=len-1;i>=2;i--)
      t[j++]=s[i]-'0';
      len-=2;
      for(i=0;i<len;i++)
      {
          int c=0;
          sc[i]+=t[i];//这步很关键哦
          for(j=0;j<=len+2;j++)
          {
              sc[j]=sc[j]*125+c;
              c=sc[j]/1000;
              sc[j]%=1000;
          }
      }
      for(i=len-1;i>=0;i--)
        printf("%03d",sc[i]);
      cout<<" [10]"<<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