HDOJ 1063 Exponentiation(小数高精度)
来源:互联网 发布:java 声明base64 编辑:程序博客网 时间:2024/05/16 14:44
小数的幂,就是太麻烦。c++手写高精度。
#include<stdio.h>#include<string.h>#include<math.h>#define MAX 100000const double eps = 1e-12;int main(){ int n, i, j, flag, d, s; int a[MAX]; double t; while (scanf("%lf %d", &t, &n) != EOF) { int c = 0; if ((int)t == 0) flag = 0; else flag = 1; t += eps; //由于double储存特性,0.4321储存会储存为0.4320999999999 while (fabs((int)t - t) > 1e-5) { t *= 10; c ++; if (c == 5) break; } s = (int)t; memset(a, 0, sizeof(a)); d = 1; a[0] = 1; for (i = 0; i < n; i ++) { for (j = 0; j < d; j ++) a[j] = a[j] * s; for (j = 0; j < d; j ++) { if (a[j] > 9) { if (j == d - 1) d ++; a[j+1] += a[j] / 10; a[j] = a[j] % 10; } } } if (d <= c * n && flag == 0) { printf("."); for (j = 0; j < c * n - d; j ++) printf("0"); for (i = d - 1; i >= 0; i --) printf("%d", a[i]); } else { for (i = d - 1; i >= 0; i --) { if (i + 1 == c * n) printf("."); printf("%d", a[i]); } } printf("\n"); } return 0;}
0 0
- HDOJ 1063 Exponentiation(小数高精度)
- hdu 1063 Exponentiation (高精度小数乘法)
- hdu1063 Exponentiation 高精度小数
- HDU 1063 Exponentiation (高精度)
- poj 1001 uva 748 Exponentiation(高精度小数乘法)
- HDOJ 4957 Poor Mitsui(小数高精度)
- POJ 1001 Exponentiation 高精度小数相乘
- JAVA hdu 1063 Exponentiation(高精度)
- HDU 1063 Exponentiation(高精度求幂)
- Exponentiation(高精度)
- Exponentiation(高精度)
- HDOJ 1063 Exponentiation
- HDOJ 1063 Exponentiation
- HDOJ 1063 Exponentiation
- ACM HDOJ 1063 (Exponentiation)
- HDOJ 1063 Exponentiation
- HDOJ 1063 Exponentiation
- hdu 1063 Exponentiation(java+高精度)
- 神雕侠侣网络文件排序与替换
- fl2440 的菜鸟学习之路1
- Linux基础知识---Shell编程之正则表达式
- java JNDI介绍
- 四个开源商业智能平台比较(二)
- HDOJ 1063 Exponentiation(小数高精度)
- 详解java中staitc关键字
- Mac OS 系统 做 USB bootable 启动盘
- java.util.Date和java.sql.Date的区别和相互转化
- jQuery Ui Draggable在移动端浏览器不起作用解决方案
- 四个开源商业智能平台比较(三)
- hive表中json字符串转map的处理
- apache kafka性能测试命令使用和构建kafka-perf
- ios8 关于定位的一些问题