poj 1001 Exponentiation

Exponentiation

Time Limit: 500MS

Memory Limit: 10000K

Total Submissions: 109780

Accepted: 26662

Description

Problemsinvolving the computation of exact values of very large magnitude and precisionare common. For example, the computation of the national debt is a taxingexperience 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 <99.999 ) and n is an integer such that 0 < n <= 25.

Input

The inputwill consist of a set of pairs of values for R and n. The R value will occupycolumns 1 through 6, and the n value will be in columns 8 and 9.

Output

The outputwill 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 zerosmust not be printed. Don't print the decimal point if the result is an integer.

Sample Input

95.123 12

0.4321 20

5.1234 15

6.7592  9

98.999 10

1.0100 12

Sample Output

548815620517731830194541.899025343415715973535967221869852721

.00000005148554641076956121994511276767154838481760200726351203835429763013462401

43992025569.928573701266488041146654993318703707511666295476720493953024

29448126.764121021618164430206909037173276672

90429072743629540498.107596019456651774561044010001

1.126825030131969720661201

Hint

If youdon't know how to determine wheather encounted the end of input: 
s is a string and n is an integer 

 

求幂

Time Limit: 500MS

Memory Limit: 10000K

Total Submissions: 109780

Accepted: 26662

Description

涉及高精度计算的问题是很常见的. 比如说,计算国债,就是一项费力的工程
这个问题要求你写个程序来计算Rn ,其中R是个实数( 0.0 <R < 99.999 ),n是个整形数(0 < n<= 25)

Input

输入将包含几组数据,R和n。R占6列,n占第8,9列

Output

输出将对每一组数据计算出一个R^n 。开头和尾巴的零应该省略,如果是整形数,不应该有小数点存在。

Sample Input

95.123 12

0.4321 20

5.1234 15

6.7592  9

98.999 10

1.0100 12

Sample Output

548815620517731830194541.899025343415715973535967221869852721

.00000005148554641076956121994511276767154838481760200726351203835429763013462401

43992025569.928573701266488041146654993318703707511666295476720493953024

29448126.764121021618164430206909037173276672

90429072743629540498.107596019456651774561044010001

1.126825030131969720661201

Hint

If youdon't know how to determine wheather encounted the end of input: 
s is a string and n is an integer 

 

这代码重新写的看起来好看点依然很破,求高速算法…….

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
void Exponen(char *s, int n, char *res);
void Output(char *res, int point);
void init(char *s, int *point);
void multi(char *res, char*s);
 
int main()
{
   char s[6];
    char res[555];
   int n;
 
   freopen("in.txt", "r", stdin);
   while(~scanf("%s %d", s, &n)){
       //puts("o");
       Exponen(s,n,res);
    }
 
   return 0;
}
 
void init(char *s, int *point){
   int k = 5, p = 0, i;
   char s1[6];
   while((*(s+k))=='0')  {k--;}//消除小数点后多余的0
   for (i = k;i >= 0; i--){//记录小数点位置,并将处理后的数给一个新字符串。
       if (s[i] == '.'){
           *point = i;
           (*point) = k - (*point);
           //printf("%d\n", *point);
       }else{
           s1[p++] = s[i];
        }
    }
   s1[p] = 0;
   p--;
   while(*(s1+p)=='0') {*(s1+p) = 0;p--;}//消除最前面的多余的0
   strcpy(s, s1);//拷贝回s
}
 
void multi(char *res, char*s){
   int i, j;
   int p, q, k, cnt;
   char temp[555]={0};
    p= 0;q = 0;
   while(p != strlen(s)){
       k = p;
       cnt = 0;
       while(q != strlen(res)){
           *(temp + k) += (*(res + q)-'0') * (*(s + p)-'0') + cnt;
           //printf("\n");
           //printf("here = %d, k = %d, pro = %d, next = %d\n", *(temp +k), k, *(res + q)-'0', *(s + p)-'0');
           cnt = *(temp + k) / 10;
           *(temp + k) %= 10;
           k ++;
           q ++;
       }
       *(temp + k) += cnt;//最后一个进位要加上
       q = 0;
       p ++;
    }
 
   //printf("\n");
   for (i = 0;i <= k;i ++){
        temp[i]+='0';
    }
   if (*(temp + k) != '0')
       temp[k+1] = 0;
   else temp[k] = 0;
   strcpy(res, temp);
}
 
void Exponen(char *s, int n, char *res){
   int i, point=-1, pointt;
   init(s, &point);//初始化字符串,方便运算
 
   strcpy(res, s);//res作为主串
   //printf("%s\n", res);
 
   pointt = point;
   //printf("%d\n", pointt);
   for (i = 0;i < n -1;i ++){
       point += pointt;
    }
   //printf("point = %d\n", point);
   for (i = 0; i < n - 1;i ++){
       multi(res,s);
       //printf("res=%s\n", res);
    }
   Output(res, point);
   //printf("%s\n", res);
}
 
void Output(char *res, int point){
   int len = strlen(res);
   int p, ps;
   if (len >= point){//长度大于
       //point = len - point;
       ps = len;p = len-1;
       while((ps != -1) && (p != -1)){
           if (ps == point){
                putchar('.');ps--;
           }else {
                printf("%c",*(res+p));p--;ps--;
           }
       }
   }else{
       putchar('.');
       p = point;
       while(p != 0){
           if (p > len){
                putchar('0');p--;
           }else{
                p--;
                printf("%c",*(res+p));
           }
       }
 
    }
   putchar('\n');
}


内容概要:本文介绍了DeepSeek在职场中的应用,从提示语技巧到多场景应用,涵盖了DeepSeek的基础模型(V3)、深度思考模型(R1)及其联网搜索功能。文中详细描述了DeepSeek的模型对比,包括操作规范、结果导向、路径灵活性、响应模式和风险特征等方面。此外,还探讨了DeepSeek在制作可视化图表、PPT、海报、视频以及批量生成新媒体文案等具体应用场景中的使用方法和技巧。最后,文章展示了DeepSeek在市场调查、AI应用开发等方面的应用实例,强调了其在人机协同和共生领域的潜力。 适用人群:适用于希望提升工作效率和创新能力的职场人士,特别是从事数据分析、内容创作、市场营销、AI开发等领域的专业人士。 使用场景及目标:①通过DeepSeek的基础模型(V3)和深度思考模型(R1)进行高效的任务处理和复杂推理;②利用DeepSeek制作可视化图表、PPT、海报和视频,提高内容创作的质量和效率;③通过DeepSeek进行市场调查和AI应用开发,优化业务流程并推动创新。 其他说明:DeepSeek不仅提供了强大的AI工具,还强调了人机协同的重要性。用户在使用过程中应注意操作规范,结合实际需求选择合适的模型,并充分利用DeepSeek的各项功能来实现高效的职场应用。文中还提到了多个国际竞赛中的获奖情况,展示了DeepSeek团队在AI领域的卓越实力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值