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 ...
随机推荐
- 关于配置tnsnames来使用PLSQL连接数据库
关于配置tnsnames来使用PLSQL连接数据库 要想用ORACLE SQLdeveloper或者第三方工具PLSQLdeveloper.Toad等连接ORACLE数据库,必需要配置TNSnames ...
- PHP安全编程:会话数据注入 比会话劫持更强大的攻击(转)
一个与会话暴露类似的问题是会话注入.此类攻击是基于你的WEB服务器除了对会话存储目录有读取权限外,还有写入权限.因此,存在着编写一段允许其他用户添加,编辑或删除会话的脚本的可能.下例显示了一个允许用户 ...
- Change value of string array at debug eclipse--转
Question: I have an application, but to test something, I need to change value of a String[]. But wh ...
- [转] __thread关键字
http://blog.csdn.net/liuxuejiang158blog/article/details/14100897 __thread是GCC内置的线程局部存储设施,存取效率可以和全局变量 ...
- iOS 开发-单元测试
前言 维基百科对单元测试的定义如下: 在计算机编程中,单元测试(英语:Unit Testing)又称为模块测试, 是针对程序模块(软件设计的最小单位)来进行正确性检验的测试工作.程序单元是应用的最小可 ...
- 获取context path或者basePath
转自:http://hexudonghot.blog.163.com/blog/static/532043422012112264411234/ 在jsp中获取context path或者basePa ...
- 完美解决Android完全退出程序(转)
背景:假说有两个Activity, Activity1和Activity2, 1跳转到2,如果要在2退出程序,一般网上比较常见的说法是用 System.exit(0) 或是 android.os.Pr ...
- 第五章:最后一步准备,1.8的Json模型、状态描述机制详解
<基于1.8 Forge的Minecraft mod制作经验分享> 1.8的所有纹理材质都需要一个Json来对其描述,这一块感觉是各大神的教程里面涉及最少最浅的,我就斗胆在这分享下我研究了 ...
- Creating a Navigation Drawer 创建一个导航侧边栏
The navigation drawer is a panel that displays the app’s main navigation options on the left edge of ...
- 0_Linux_虚拟机安装
虚拟机的安装0Snapshot和clone 系统分区(由硬盘的性能所限制的) 1分区类型: 主分区:最多有4个 扩展分区:最多只能有1个:主分区加扩展分区最多有4个:不能写入数据,只能包含逻辑分区,不 ...