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 16281044 at 2019-05-20 19:32:22 on Problem 1001
#include<stdio.h>
#include<string.h>

int a[100000],b[100000],backup[6],pingfangCount,pointPosition=-1,aL=0,bL=0,buL=0;

void mutipl(){
    memset(b,0,sizeof(b));
    for(int i = 0; i < buL; i++)
    {
        for (int j = 0; j < aL; j++)
        {
            b[i+j] += backup[i]*a[j];
            if(i+j>=bL&&b[i+j]!=0) bL = i+j+1;
            if(b[i+j]>9){
                int save = b[i+j]%10;
                b[i+j+1] += b[i+j]/10;
                b[i+j] = save;
                if(i+j+1>=bL&&b[i+j+1]!=0) bL = i+j+2;
            }
        }
    }
    for(int i=0;i<bL;i++)
        a[i]=b[i];
    aL=bL;
}

int main(){
    char str[10];
    char pingstr[5];
    int hz = 1;
    int zeros = 0;
    for(;scanf("%s %s",str,pingstr)==2;)
    {
        for(int i=5;i>=0;i--)
        {
            if(str[i]!='.'){
                backup[buL++]=str[i]-'0';
                if(str[i]=='0'&&hz) zeros++;
                else hz = 0;
            }else
            {
                pointPosition = 5-i;
                hz = 0;
            }
        }

        if(zeros==buL){printf("0\n");
            memset(str,'\0',10);
            memset(pingstr,'\0',5);
            memset(backup,'0',6);
            pointPosition = -1;
            pingfangCount = 0;
            aL=0;
            bL=0;
            buL=0;
            hz = 1;
            zeros =0;
            continue;}

        for(int i=0;i<=1;i++)
            if(pingstr[i]!='\0')
                pingfangCount = 10*pingfangCount+pingstr[i]-'0';
        a[0]=1;aL=1;

        for(int i=pingfangCount;i>0;i--)
            mutipl();

        if(pointPosition==-1)
        {
            for(int i=aL-1; i>=0; i--)
                printf("%d",a[i]);
        } else
        {
            if(pingfangCount*pointPosition<aL)
                for(int i=aL-1; i>=zeros*pingfangCount; i--)
                    if(pingfangCount*pointPosition==i&&i!=zeros*pingfangCount)
                        printf("%d.",a[i]);
                    else
                        printf("%d",a[i]);
            else
                for(int i=pingfangCount*pointPosition; i>=zeros*pingfangCount; i--)
                    if(i==pingfangCount*pointPosition&&i!=zeros*pingfangCount)
                        printf(".");
                    else if(i<=aL-1)
                        printf("%d",a[i]);
                    else
                        printf("0");
        }
        memset(str,'\0',10);
        memset(pingstr,'\0',5);
        memset(backup,'0',6);
        pointPosition = -1;
        pingfangCount = 0;
        aL=0;
        bL=0;
        buL=0;
        hz = 1;
        zeros =0;
        putchar('\n');
    }
    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