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 = ...
随机推荐
- C++死锁解决心得
一. 概述C++多线程开发中,容易出现死锁导致程序挂起的现象.关于死锁的信息,见百度百科http://baike.baidu.com/view/121723.htm. 解决步骤分为三步:1.检测死锁线 ...
- iOS 数组里面取字典的值
NSArray *arrData = @[@"1",@"2",@"3",@"4"]; NSArray *arrKey = ...
- 「深入理解计算系统」从Hello World开始
从 hello world 开始 Table of Contents 1 程序源文件 2 程序源文件是什么 3 程序被编译 4 程序运行 4.1 读取命令 4.2 读取指令内容 4.3 执行过程 5 ...
- img 中的src的应用
在页面载入的时候,img标签的src 会跟填写的内容去载入,servlet 或者controller 或者你自己觉得希望载入的java代码. 我们这边举一个载入servlet的样例. <img ...
- SQL语句一些特殊的用法
SQL语句一些特殊的用法 一.基础 1.说明:创建数据库 CREATE DATABASE database-name 2.说明:删除数据库 drop database dbname 3.说明:备份s ...
- pl sql项目演练--B2C商城项目
项目学习视频下载地址:点击下载 1.注册会员及找回密码模块 }该模块主要功能有注册会员和找回密码 }注册会员:所需信息主要有:登录号.密码.真实姓名.性别.密码问题.密码答案.Email.地址.电 ...
- SQL serve创建与调用存储过程
(1)创建 2编写存储过程(创建传参的存储过程)存储过程语法网络上很多不在累述 语法解析 Use Person 指定在那个数据库下建立存储过程 if (object_id('MyFunction', ...
- 怎样使用Markdown
转自:http://wowubuntu.com/markdown/basic.html 段落.标题.区块代码 一个段落是由一个以上的连接的行句组成,而一个以上的空行则会划分出不同的段落(空行的定义是显 ...
- poj 3740 Easy Finding 精确匹配
题目链接 dlx的第一题, 真是坎坷..... #include <iostream> #include <vector> #include <cstdio> #i ...
- zoj 2589 Matrix Searching 二维线段树
题目链接 给一个n*n的矩阵, 给q个查询, 每次给出x1, y1, x2, y2, 求这个矩阵中的最小值. 代码基本上和上一题相同... #include<bits/stdc++.h> ...