poj 2389 Bull Math
来源:互联网 发布:js object 增加属性 编辑:程序博客网 时间:2024/05/01 05:50
大数相乘的模板。。
自己写一个竖式就明白了。。
malloc一下更机智。。
#include<cstdio>#include<cstring>#include<iostream>#include<cstring>#include<algorithm>using namespace std;#define maxn 10010void cheng(char *a,char *b){ int alen=strlen(a); int blen=strlen(b); int ans[maxn*2]={0}; char c[maxn]; for(int i=0;i<alen;i++) { for(int j=0;j<blen;j++) { ans[i+j+1]+=(a[i]-'0')*(b[j]-'0'); } } for(int i=alen+blen-1;i>=0;i--) { if(ans[i]>=10) { ans[i-1]+=ans[i]/10; ans[i]=ans[i]%10; } } int i=0,j; while(ans[i]==0) { i++; } for(j=0;i<alen+blen;j++,i++) { c[j]=ans[i]+'0'; } c[j]='\0'; cout<<c<<endl;}char a[maxn],b[maxn];int main(){ while(scanf("%s%s",a,b)==2) { cheng(a,b); } return 0;}
0 0
- poj 2389 Bull Math
- POJ 2389 Bull Math
- POJ 2389 Bull Math
- poj 2389 Bull Math
- poj 2389 Bull Math
- POJ 2389 Bull Math JAVA .
- poj 2389 Bull Math 高精度乘法模板
- poj 2389 Bull Math java解决!!
- POJ 2389 Bull Math --from lanshui_Yang
- poj 2389 Bull Math(高精度加法)
- POJ--2389:Bull Math 大数乘法
- Poj OpenJudge 百练 2389 Bull Math
- POJ 2389 Bull Math(FFT)
- POJ 2389 Bull Math (FFT)
- POJ 2389 Bull Math 高精度(大数)乘法 模板
- poj 2389Bull Math(大整数乘法, 水题)
- POJ 2389 Bull Math(大数乘法,还是Java好)
- poj 2389 Bull Math(可做大数相乘模板)
- 直接插入排序
- 二值化算法之(一) --- OTSU二值化
- QML 与 C++ 交互之工厂方法
- maven 仓库网站地址
- makefile文件测试
- poj 2389 Bull Math
- 冒泡排序
- 安卓开发GitHub的入门使用流程---》适合小学生
- opencv 画直线,椭圆,多边形操作
- SGU 176 有源汇上下界的最小流
- 数据上传
- iOS 排序方法
- js数组基本知识
- 直接选择排序