BZOJ1754: [Usaco2005 qua]Bull Math
1754: [Usaco2005 qua]Bull Math
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 374 Solved: 227
[Submit][Status]
Description
huge integers together and get perfectly precise answers ... or so
they say. Farmer John wonders if their answers are correct. Help
him check the bulls' answers. Read in two positive integers (no
more than 40 digits each) and compute their product. Output it as
a normal number (with no extra leading zeros).
FJ asks that you do this yourself; don't use a special library
function for the multiplication.
输入两个数,输出其乘积
Input
Output
Sample Input
1111111111
Sample Output
HINT
Source
题解:
呵呵,金组出这种题,防爆零呢吧。。。
代码:
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 10000
#define maxm 500+100
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define mod 1000000007
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}
return x*f;
}
int n,m,a[maxn],b[maxn],c[maxn];
char ch;
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
ch=getchar();
while(ch<=''&&ch>='')a[++n]=ch-'',ch=getchar();
for1(i,n>>)swap(a[i],a[n+-i]);
ch=getchar();
while(ch<=''&&ch>='')b[++m]=ch-'',ch=getchar();
for1(i,m>>)swap(b[i],b[m+-i]);
for1(i,n)
for1(j,m)
c[i+j-]+=a[i]*b[j];
for1(i,n+m)c[i+]+=c[i]/,c[i]%=;
int t=n+m;
while(!c[t])t--;
for3(i,t,)printf("%d",c[i]);
printf("\n");
return ;
}
BZOJ1754: [Usaco2005 qua]Bull Math的更多相关文章
- 1754: [Usaco2005 qua]Bull Math
1754: [Usaco2005 qua]Bull Math Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 398 Solved: 242[Submit ...
- BZOJ 1754: [Usaco2005 qua]Bull Math
Description Bulls are so much better at math than the cows. They can multiply huge integers together ...
- 【BZOJ】1754: [Usaco2005 qua]Bull Math
[算法]高精度乘法 #include<cstdio> #include<algorithm> #include<cstring> using namespace s ...
- bzoj 1754: [Usaco2005 qua]Bull Math【高精乘法】
高精乘法板子 然而WA了两次也是没救了 #include<iostream> #include<cstdio> #include<cstring> using na ...
- Poj OpenJudge 百练 2389 Bull Math
1.Link: http://poj.org/problem?id=2389 http://bailian.openjudge.cn/practice/2389/ 2.Content: Bull Ma ...
- bzoj1751 [Usaco2005 qua]Lake Counting
1751: [Usaco2005 qua]Lake Counting Time Limit: 5 Sec Memory Limit: 64 MB Submit: 168 Solved: 130 [ ...
- 1755: [Usaco2005 qua]Bank Interest
1755: [Usaco2005 qua]Bank Interest Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 187 Solved: 162[Su ...
- 1753: [Usaco2005 qua]Who's in the Middle
1753: [Usaco2005 qua]Who's in the Middle Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 290 Solved: ...
- 1751: [Usaco2005 qua]Lake Counting
1751: [Usaco2005 qua]Lake Counting Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 190 Solved: 150[Su ...
随机推荐
- Solaris下怎样改动文件创建时间及查询
Solaris下怎样改动文件创建时间及查询 实验演示: 1.核对时间 [root@S1011:/]# date Tue Jul 15 21:37:01 CDT 2014 --若时间不对请先按例如以下格 ...
- Tcpdump命令行 与 GUI Wireshark
http://www.cnblogs.com/ggjucheng/archive/2012/01/14/2322659.html tcpdump host 192.168.1.26 and \(192 ...
- [转] 使用memc-nginx和srcache-nginx模块构建高效透明的缓存机制
为了提高性能,几乎所有互联网应用都有缓存机制,其中Memcache是使用非常广泛的一个分布式缓存系统.众所周知,LAMP是非常经典的Web架构方式,但是随着Nginx的 成熟,越来越多的系统开始转型为 ...
- Linux 信号表
信号 取值 默认动作 含义(发出信号的原因) SIGHUP 1 Term 终端的挂断或进程死亡 SIGINT 2 Term 来自键盘的中断信号 SIGQUIT 3 Core 来自键盘的离开信号 SIG ...
- 模板-->Matrix重载运算符:+,-,x
如果有相应的OJ题目,欢迎同学们提供相应的链接 相关链接 所有模板的快速链接 poj_2118_Firepersons,my_ac_code 简单的测试 INPUT: 1 2 3 1 3 4 3 -1 ...
- FineUI开发实践-目录
点我订阅 目前所有博客的截图,方便离线观看,点图片 FineUI初学手册 下载,实例项目搭建 FineUI初学手册-部分JS整理 部分JS整理 ASP.NET-FineUI开发实践-1 实际开发环境是 ...
- 很棒的jQuery代码片段分享
jQuery实现的内链接平滑滚动 不需要使用太复杂的插件,只要使用下载这段代码即可实现基于内部链接的平滑滚动 $('a[href^="#"]').bind('click.smoot ...
- Smarty的配置与高级缓存技术
转之--http://www.cnblogs.com/-run/archive/2012/06/04/2532801.html Smarty 是一个出色的PHP模板引擎,它分离了逻辑代码和user i ...
- Oracle 创建分页存储过程(转帖)
原贴地址:http://19880614.blog.51cto.com/4202939/1316560 ps:源代码还有很多错误,我修改了 ------------------------------ ...
- 【USACO 2.4.3】牛的旅行
[描述] 农民 John的农场里有很多牧区.有的路径连接一些特定的牧区.一片所有连通的牧区称为一个牧场.但是就目前而言,你能看到至少有两个牧区通过任何路径都不连通.这样,Farmer John就有多个 ...