Problem E: Product
Problem E: Product
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 18 Solved: 14
[Submit][Status][Web Board]
Description
The problem is to multiply two integers X, Y. (0<=X,Y<10250)
Input
The input will consist of a set of pairs of lines. Each line in pair contains one multiplyer.
Output
For each input pair of lines the output line should consist one integer the product.
Sample Input
12
12
2
222222222222222222222222
Sample Output
144
444444444444444444444444
my answer:
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int main()
{ char a[];
char b[];
memset(a,'',sizeof(a));
memset(b,'',sizeof(b));
while(cin>>a>>b)
{
int sum[]={};
int t1=strlen(a);
int q=t1;
int t2=strlen(b);
for(int i=t2-;t2>,i>=;i--){
int p=;
for(int j=q-,p=+i-t2+;j>=;t1--){
sum[p--]+=((a[j--]-'')*(b[i]-''));
}
}
for(int k=;k>=;k--){
sum[k-]+=sum[k]/;
sum[k]=sum[k]%;
}
int start=;
while(!sum[start])
start++;
for(int j=start;j<=;j++)
cout<<sum[j];
cout<<endl;
}
return ;
}
Problem E: Product的更多相关文章
- projecteuler---->problem=8----Largest product in a series
title: The four adjacent digits in the 1000-digit number that have the greatest product are 9 9 8 9 ...
- projecteuler---->problem=11----Largest product in a grid
In the 2020 grid below, four numbers along a diagonal line have been marked in red. 08 02 22 97 38 1 ...
- Project Euler Problem 8-Largest product in a series
直接暴力 写完才想到,代码写矬了,扫一遍就出结果了,哪还用我写的这么麻烦 ss = '''73167176531330624919225119674426574742355349194934 9698 ...
- UVA11059-Maximum Product(动态规划)
Problem UVA11059-Maximum Product Accept:4769 Submit:38713 Time Limit: 3000 mSec Problem Descriptio ...
- 【转载】Bandits for Recommendation Systems (Part I)
[原文链接:http://engineering.richrelevance.com/bandits-recommendation-systems/.] [本文链接:http://www.cnblog ...
- Contest2073 - 湖南多校对抗赛(2015.04.06)
Contest2073 - 湖南多校对抗赛(2015.04.06) Problem A: (More) Multiplication Time Limit: 1 Sec Memory Limit: ...
- Java 解决一些ACM中大数问题
大数中算术运算结果的首选标度 运算 结果的首选标度 加 max(addend.scale(), augend.scale()) 减 max(minuend.scale(), subtrahend.sc ...
- 1561: (More) Multiplication
Description Educators are always coming up with new ways to teach math to students. In 2011, an educ ...
- projecteuler Problem 8 Largest product in a series
The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = ...
随机推荐
- oracle sql命令行中上下左右使用
yum -y install readline,rlwrap
- 初探swift语言的学习笔记(闭包 - 匿名函数或block块代码)
很多高级语言都支持匿名函数操作,在OC中的block也为大家所熟悉,然面在swift里好像是被重新作了一个定义,不叫匿名函数,或 block了,而叫闭包(closure).下面配合代码来理解一下swi ...
- MVC多表联合查询数据显示
随然做过几年.net开发,但一直没有做过MVC框架下的网站,这段时间无事,学习一下.下面的方法是我摸索过程中的一点总结,如果有更好的方法,欢迎告诉我,谢谢. 这段时间我只看了MVC和LinQ两本书,关 ...
- sql server 2005 表master..spt_values
IF OBJECT_ID('tempdb..#t') IS NOT NULL DROP TABLE #tGOcreate table #t(id int identity,Dt varchar(10) ...
- ArcMap制图_显示指定区域地图内容
摘要:有一张完整的中国地图,有时仅要求针对某一特定区域制图,那么如何在不进行裁剪的情况下仅显示该区域范围的要素内容? 步骤: 1.打开ArcMap,加载完整的中国地图: 2.将要显示的区域范围制作成一 ...
- WebPart设置杂项
CS写法: } 后台写法: public D_ZoneLimitView WebPart { get; set; }
- Win32下C++遍历目录和文件的源码
#include<windows.h> #include<iostream> #include<string> using namespace std; //只能处 ...
- NOPI导出Excel 自定义列名
NOPI 做Excel 导出确实很方便 ,但是一直在用没好好研究. 在网上没找到自定义Columns的方法 ,于是乎自己就在原来的方法上简单地改改. 想用的童鞋们可以直接拿去用! /// 数据大于65 ...
- 用例图(UseCase Diagram)—UML图(一)
从上面的用例图模型,我们可以大致了解用例图所描述的是什么.下面进行详细介绍. 用例图,即用来描述什么角色通过某某系统能做什么事情的图,用例图关注的是系统的外在表现,系统与人的交互,系统与其它系统的 ...
- C++_前置声明
为什么要有前置声明? eg: -定义一个类 class A,这个类里面使用了类B的对象b,然后定义了一个类B,里面也包含了一个类A的对象a,就成了这样: //a.h #include "b. ...