bzoj1754: [Usaco2005 qua]Bull Math
来源:互联网 发布:绝知此事要躬行意思 编辑:程序博客网 时间:2024/05/22 23:59
高精度乘法模板。。。
#include<iostream>#include<cstdio>#include<cmath>#include<algorithm>#include<cstring>using namespace std;int main(void){ string m,n; cin>>m>>n; int p,q; p=m.size(); q=n.size(); int s=p+q; int a[s]; memset(a,0,sizeof a); for(int i=p-1;i>=0;i--){ for(int j=q-1;j>=0;j--){ a[p-1-i+q-1-j]+=(m[i]-48)*(n[j]-48)%10; a[p-1-i+q-1-j+1]+=(m[i]-48)*(n[j]-48)/10; for(int k=p-1-i+q-1-j;k<s;k++){ if(a[k]>=10) {a[k+1]+=a[k]/10;a[k]=a[k]%10; } } } } if(a[s-1]==0){for(int i=s-2;i>=0;i--){cout<<a[i]; } } else {for(int i=s-1;i>=0;i--){cout<<a[i]; } }}
阅读全文
0 0
- bzoj1754 [Usaco2005 qua]Bull Math
- bzoj1754: [Usaco2005 qua]Bull Math
- bzoj1754 [Usaco2005 qua]Bull Math
- 1754: [Usaco2005 qua]Bull Math (高精度乘法)
- bzoj 1754: [Usaco2005 qua]Bull Math
- BZOJ 1754: [Usaco2005 qua]Bull Math 高精乘
- Bull Math
- bzoj1755 [Usaco2005 qua]Bank Interest
- 1755: [Usaco2005 qua]Bank Interest
- bzoj1751 [Usaco2005 qua]Lake Counting
- bzoj1750 [Usaco2005 qua]Apple Catching
- bzoj1755 [Usaco2005 qua]Bank Interest
- bzoj1751 [Usaco2005 qua]Lake Counting
- [bzoj1751][Usaco2005 qua]Lake Counting
- bzoj1755 [Usaco2005 qua]Bank Interest
- 1751: [Usaco2005 qua]Lake Counting (搜索)
- 1750: [Usaco2005 qua]Apple Catching (动态规划)
- bzoj 1751 [Usaco2005 qua]Lake Counting
- 树莓派的首次连接
- redux的中间件(middleware)
- 华为2018届校招勇敢星实习生招聘笔试+面试经历
- Eclipse 搭建SSM(Spring、Spring MVC 、Mybatis)
- NAT技术与代理服务器
- bzoj1754: [Usaco2005 qua]Bull Math
- 走向云计算之Hive基本架构和使用详解
- VC++ .Net 实例学习
- day05
- oracle --查询语句
- hashmap和hashset的理解,关于hashcode和equals。
- 两个路由器下的电脑怎么互相访问、控制
- 无状态服务
- STM32 SPI 模拟实现 W25X16读写 代码