高精度 A*B Problem
来源:互联网 发布:淘宝onlyanna真名晓颖 编辑:程序博客网 时间:2024/05/17 01:28
题目:请戳此处
#include<stdio.h>#include<stdlib.h> #include<string.h>char s[30000],l[30000];long long a[30001],b[30001],c[60000],al,bl,cl,i,j,x;int main(){gets(s); al=strlen(s); for (i=0;i<(5-al%5)%5;i++){ strcpy(l,s); strcpy(s,"0"); strcat(s,l); } if (al%5!=0) al=(al/5+1)*5; for (i=0;i<al/5;i++) a[i+1]=(s[al-i*5-1]-'0')+(s[al-i*5-2]-'0')*10+(s[al-i*5-3]-'0')*100+(s[al-i*5-4]-'0')*1000+(s[al-i*5-5]-'0')*10000; gets(s); bl=strlen(s); for (i=0;i<(5-bl%5)%5;i++){ strcpy(l,s); strcpy(s,"0"); strcat(s,l); } if (bl%5!=0) bl=(bl/5+1)*5; for (i=0;i<bl/5;i++) b[i+1]=(s[bl-i*5-1]-'0')+(s[bl-i*5-2]-'0')*10+(s[bl-i*5-3]-'0')*100+(s[bl-i*5-4]-'0')*1000+(s[bl-i*5-5]-'0')*10000; for (i=1;i<=bl/5;i++) for (j=1;j<=al/5;j++) c[i+j-1]=c[i+j-1]+a[j]*b[i]; for (i=1;i<=al/5+bl/5;i++){ c[i+1]=c[i+1]+c[i]/100000; c[i]=c[i]%100000; } x=0; for (i=al/5+bl/5;i>0;i--){ if (c[i]!=0 && x==0){ x=1; cl=i; } if (x){ if(i<cl){ if (c[i]<10) printf("0"); if (c[i]<100) printf("0"); if (c[i]<1000) printf("0"); if (c[i]<10000) printf("0"); } printf("%d",c[i]); } } if (x==0) printf("0"); puts(""); return 0;}
2 0
- A+B Problem 高精度
- 高精度 A*B Problem
- 高精度 A+B Problem
- 高精度 A-B Problem
- NYOJ-524 A-B Problem【高精度】
- USTC1046 A * B Problem 高精度乘法模板
- A * B Problem (Big integer version) 【高精度】
- A * B Problem (Big integer version) 【高精度】
- A + B Problem (Big integer version) 【高精度】
- HDU 1002 A+B Problem 高精度加法
- 高精度-HDU-1002-A + B Problem II
- hdu1002 A + B Problem II(高精度加法)
- A + B Problem II(高精度加法)
- 高精度——A*B Problem
- 【高精度】洛谷 P1303 A*B Problem
- A + B Problem II 【java 高精度】
- HDU 1402 A * B Problem Plus 高精度乘法
- 1002—A + B Problem II(高精度)
- linux shell 编程11 特殊符号总结:$0 $1 $2 $# $* $@ $! $$ $?
- hdu 5195 DZY Loves Topological Sorting【拓扑排序+优先队列+邻接表】
- Linux下阅读MHT文件
- UVa 1225 Digit Counting
- Eclipse集成反编译插件jd-Eclipse
- 高精度 A*B Problem
- 测试人员素质了解
- 自定义动画
- WEB服务器相关开发(存档)
- 推荐7款用于PHP的代码调试工具
- DBA解题集:也谈闭环时
- eclispe debug 关键点汇总
- 微信涉及的重要数据结构-1
- 蓝桥杯入门