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 = ...
随机推荐
- Qt编写端口扫描工具
Qt提供了QTcpSocket类,可以方便地建立TCP连接.利用这一功能,Maxiee编写了一个简单地端口扫描工具. 软件的功能就是,扫描某一网段的固定端口,如80端口,若目的地址开放了这一端口,那么 ...
- 使用sphinx索引mysql数据
数据库表如下 mysql> select * from tb_account; +----+-------+------+ | id | name | age | +----+-------+- ...
- jeecms 2012 源码分析(2) 前台栏目页静态化分析
还是要说到web.xml文件 <welcome-file-list> <welcome-file>index.html</welcome-file> <wel ...
- 百度Map调用
baiduMap API 根据地址查询经纬度 http://api.map.baidu.com/geocoder?address=要查询的地址&output=json&key=你的ke ...
- 【转】在SQL Server 2008中SA密码丢失了怎么办?
sql server 2008的sa用户莫名其妙就登陆不进去了.提示如下: 以上提示就表明是密码错误,但密码我可是记得牢牢的,也许是系统被黑的原因吧.一直以来我的Windows身份验证就用不起,以下方 ...
- WebService测试工具SoapUI
尊重原著作:本文转载自http://gqsunrise.iteye.com/blog/1958480 1. 简介 SoapUI是用java开发的测试web service的工具. 2. 安装 2.1. ...
- 测试heightlight
var a = '综合型律师事务所'; if (a == '综合型律师事务所') { initradio('ls_classes', '综合型律师事务所'); } else { initradio(' ...
- leetcode Longest Common Prefix python
class Solution(object): def longestCommonPrefix(self, strs): """ :type strs: List[str ...
- Java中的流程控制(一)
程序的流程控制(一) 关于Java程序的流程控制(一) 从结构化程序设计角度出发,程序有三种结构: 顺序结构 选择结构 循环结构 1.顺序结构 就是程序从上到下一行行执行,中间没有判断和跳转. 2.i ...
- 找出n个数中出现了奇数次的两个数
如果是找只出现了奇数次的一个数, 那么我们从头异或一遍就可以. 那么如何找出现了奇数次的两个数呢? 首先我们还是从头异或一遍, 然后结果肯定不为0, 对于异或出来的结果, 如果这个数的某一位是1, 说 ...