POJ 2845
#include <iostream>
#include <string>
#include <algorithm>
#define MAXN 350
using namespace std; int _m[MAXN]; int main()
{
//freopen("acm.acm","r",stdin);
int n;
string s_1;
string s_2;
int len_1;
int len_2;
int min;
int i;
int j;
int time = ;
bool boo;
cin>>n; while(n --)
{ cin>>s_1>>s_2;
boo = false;
len_1 = s_1.length();
len_2 = s_2.length();
if(len_1 > len_2)
{
iter_swap(&s_1,&s_2);
} min = s_2.length() - s_1.length();
for(i = ; i < min; ++ i)
{
_m[i] = s_2[i] - '';
}
j = ;
for(i = min; i < s_2.length(); ++ i)
{
_m[i] = (s_2[i] - '') + (s_1[j] - '');
++ j;
} int tem = ; for(i = s_2.length() - ; i >= ; -- i)
{
_m[i] += tem;
tem = _m[i]/;
_m[i] %= ;
}
cout<<++time<<" ";
if(tem != )
{
cout<<tem;
boo = true;
}
i = ;
if(tem == )
{
while(_m[i] == )
{
++ i;
}
}
for(; i < s_2.length(); ++ i)
{ cout<<_m[i];
boo = true;
}
if(!boo)
{
cout<<;
}
cout<<endl;
}
}
POJ 2845的更多相关文章
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- POJ 2255. Tree Recovery
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11939 Accepted: 7493 De ...
- POJ 2752 Seek the Name, Seek the Fame [kmp]
Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17898 Ac ...
- poj 2352 Stars 数星星 详解
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...
随机推荐
- hashCode() 和equals() 区别和作用(转)
出处:https://www.jianshu.com/p/5a7f5f786b75 本章的内容主要解决下面几个问题: 1 equals() 的作用是什么? 2 equals() 与 == 的区别是什么 ...
- Win7 VS2013环境编译Squirrel 3.0.7
Squirrel是一个类似Lua,但是更面向对象的脚本语言. 国内这个介绍很少,环境配置更是没有任何文章提到,花了点时间搞定了,备忘记录下过程. 首先是下载,写本文时Squirrel最新版本为3.0. ...
- c++关键字extern的作用
1.用extern修饰变量 使用在别的在源文件定义的非静态外部变量时,需要使用extern进行说明 2.用extern修饰函数 使用在别的在源文件定义的函数时,需要使用extern进行说明 3.用ex ...
- php Amome框架 层次设计备注
层次说明: 每一级中函数都是为而且只为 上(高)一层 的文件服务的 最底层: AmemoMySql 基础数据库函数:AmemoConfig 数据库信息配置文件 再高一层: 一个文件对应一个 ...
- vue中$route 和$router的区别
在vue中会出现一种情况 const url=this.$route.query.returnURL; this.$router.push(url); $router和$route的区别傻傻的分 ...
- 学习致用九---centos7.2+vim vundle
目的,安装vim插件,vundle Vundle是Vim的插件管理插件 YouCompleteMe 简称 YCM 1.安装vundle: git clone https://github.com/ ...
- UML(一)下载与安装
三步 Step1 下载绿色版: http://www.pc6.com/softview/SoftView_64080.html Step2 下载汉化包,(提供一个地址): http://downloa ...
- leetcode - [7]Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tr ...
- activeMq之hello(java)
消息队列activeMq, 节省响应时间,解决了第三方响应时间长的问题让其他客户可以继续访问, 安装activeMq apache-activemq-5.14.0-bin\apache-activ ...
- java基础-day27
第04天 java基础加强 今日内容介绍 u Xml的综合案例 u 注解 u 类的加载 u 动态代理 第1章 注解 1.1 注解概述 l 什么是注解:Annotation注解,是一种代码级别的 ...