Vijos P1010 清帝之惑之乾隆

Vijos P1010 清帝之惑之乾隆


题目

背景

乾隆,雍正的第四子,在位60年,退位后又当了三年太上皇,终年89岁。
乾隆即位之初,实行宽猛互济的政策,务实足国,重视农桑,停止捐纳,平定叛乱等一系列活动中,充分体现了他的文治武功,乾隆帝向慕风雅,精于骑射,笔墨留于大江南北,并是一个有名的文物收藏家。清宫书画大多是他收藏的,他在位期间编纂的《四库全书》共收书3503种,79337卷,36304册,其卷数是《永乐大典》的三倍,成为我国古代思想文化遗产的总汇。
乾隆好游江南,喜欢江南的山水,喜欢江南的人文,喜欢江南的才气,同时他也喜欢江南的汉族美女。
描述

话说乾隆带着他的宰相刘罗锅和你出巡江南,被杭州城府邀请去听戏,至于什么戏,那就不知了。乾隆很高兴,撒酒与君臣共享。三更欲回住处,可是乾隆这人挺怪,他首先要到西湖边散散步,而且命令不准有人跟着他。
小醉,步于西湖岸,停于断桥前,突闻琴声悠悠,歌儿婉婉。这乐曲不哀伤不愁怅,少了一分怨女的羁绊,多了一分少女的期盼。乾隆走上前去,视其背影,为一女子手抚古琴,悠悠而唱。可是这么晚了,小女怎么还不回家呢,莫非是她起早床?乾隆走上前去,小声问道:“伊为何未宿?”,小女沉默片刻,转身而来。顿时,顿时,顿时!!!!!乾隆惊呆了!!!!哇!!!!噻!!!!!!这人,这伊!!!!原来!!!!!!!不是一个美女(狂汗ing)。小女并未回答她的话,只是与乾隆侃了侃诗。乾隆兴哉,问其曰:“不知偶能助伊否?”,小女曰:“偶无所以助,且有一事相求,愿君能解之。”
乾隆一看,立刻晕到在地,片刻而起,曰:“明日必解之”,且去。
回到家中,乾隆夜召你“入寝”,曰:“如此姑娘,如此情调,如此罗曼蒂克,竟然丢一个如此煞风景之问”,一边发气,一边把这个问题交给你。你一看,顿然发现,原来是用蝌蚪文写的:
Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experience for many computer systems.
This problem requires that you write a program to compute the exact value of Rn where R is a real number ( 0.0 < R <= 9999.9) and n is an integer such that 0 < n <= 250.
此时的你,已经是皇帝身边的小太监,自然有必要为皇上解决此题。
格式

输入格式

The input will consist of a set (less than 11) of pairs of values for R and n. The R value will occupy columns 1 through 6, and the n value will be in columns 8 to 10.
输出格式

The output will consist of one line for each line of input giving the exact value of R^n. Leading zeros should be suppressed in the output. Insignificant trailing zeros must not be printed. Don’t print the decimal point if the result is an integer.
样例1

样例输入1

95.123  2
0.4321  5
5.1234  7
6.7592  3
98.999  5
1.0100 10

样例输出1

9048.385129
.01506334182914325601
92663.3181348508776705891407804544
308.806114738688
9509420210.697891990494999
1.10462212541120451001

限制

各个测试点2s


题解

小数的高精度乘法


代码

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int ans[100005];
char s[10];

int main()
{
    int a=1,n,dot,b,t,maxn,x,j;
    while(scanf("%s%d",&s,&n)==2&&a++)
    {
         if(a!=2) puts("");
         memset(ans,0,sizeof(ans));
         ans[1]=1;b=0;maxn=1;
         for(int i=5;i>=0;i--)
          if(s[i]!='0') {
            t=i;break;
         }
         for(int i=0;i<=t;i++)
          if(s[i]!='.') b=b*10+s[i]-'0';
           else dot=(t-i)*n;
         for(int i=1;i<=n;i++)
         {
            x=0;
            for(j=1;j<=maxn||x;j++)
            {
                int now=b*ans[j]+x;
                ans[j]=now;
                x=ans[j]/10;ans[j]%=10;
            }
            if(maxn<j-1) maxn=j-1;
         }
         for(int i=maxn;i>dot;i--) printf("%d",ans[i]);
         if(dot!=0) printf(".");
         for(int i=dot;i>0;i--) printf("%d",ans[i]);

    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值