poj 1001 Exponentiation
来源:互联网 发布:垃圾桶 知乎 编辑:程序博客网 时间:2024/06/07 04:51
大数啊大数,神奇的大数
最懒的写大数了
→_→
大神的代码,懒!得!写!了!!
#include<iostream>#include<cmath>#include<cstring>#include<cstdio>#include<algorithm>#include<string>#include<vector>using namespace std;typedef string::size_type size_type;int ans[10024 + 10];void Print(int *d, int size){ for(int i = size - 1; i >= 0; --i) cout<<ans[i]<<" "; cout<<endl;}int Transfer(int *d, int size){ int res = 0; memset(ans, 0, sizeof(ans)); for(int i = 0; i < size; ++i){ res = res*10 + d[i]; ans[size-1-i] = d[i]; } return res;}void Multiply(int& size, int r){ int sh = 0; for(int i = 0; i < size; ++i){ int temp = ans[i]*r + sh; ans[i] = temp%10; sh = temp/10; } int k = size; if(sh > 0){ while(sh){ ans[k++] = sh%10; sh /= 10; } size = k; }}int main(){ string dl; int n; while(cin>>dl>>n){ size_type pos = dl.find('.', 0); int d[6] ; bool sign = 0; int index = 0; if(pos == string::npos) pos = dl.size(); /* begin-->提取出double*/ for(size_type i = 0; i < pos; ++i) if(sign){ d[index++] = dl[i] - '0'; } else if(dl[i] != '0'){ d[index++] = dl[i] - '0'; sign = 1; } size_type up = dl.size() - 1; while(dl[up] == '0') --up; for(size_type i = pos+1; i <= up; ++i) d[index++] = dl[i] - '0'; /* end */ int r = Transfer(d, index); int size = index; for(int i = 1; i < n; ++i) Multiply(size, r); int point_pos = (up - pos)*n - 1; if(point_pos > size-1){ cout<<"."; for(int i = point_pos; i >= size; --i) cout<<0; } for(int i = size - 1; i >= 0; --i){ if(i == point_pos) cout<<"."; cout<<ans[i]; } cout<<endl; } //system("pause"); return 0;}
0 0
- POJ 1001 Exponentiation
- POJ 1001 Exponentiation
- poj 1001 Exponentiation
- POJ 1001 "Exponentiation"
- poj 1001 Exponentiation
- POJ 1001 Exponentiation
- poj 1001 exponentiation
- 【POJ】1001 Exponentiation
- POJ 1001 Exponentiation
- poj 1001Exponentiation
- 《POJ 1001》 Exponentiation
- POJ 1001 Exponentiation
- [POJ]1001 Exponentiation
- POJ-1001-Exponentiation
- [poj] 1001 Exponentiation
- POJ 1001 Exponentiation
- poj 1001 Exponentiation
- POJ-1001 Exponentiation 高精度
- win8 64bit下srilm+cygwin实现ngram语言模型
- 设计模式六大原则
- 控制上实现的连连看
- 用泛型实现rust返回类型自动推导
- Linux文本编辑器Vim
- poj 1001 Exponentiation
- 黑马程序员——集合——Collection和单列集合List
- PAT Basic level practice 06
- selenium测试框架篇,页面对象和元素对象的管理
- 一个简易版的新闻应用(同时兼容手机和平板)
- 浅谈你对面向对象编程的认识
- 图解 android studio 如何添加 jar 文件
- WPF开发之WPF简介
- ECMAScript6学习笔记《一》-----ECMAScript 6是什么?