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个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...
随机推荐
- 2018.11.01 loj#2319. 「NOIP2017」列队(线段树)
传送门 唉突然回忆起去年去noipnoipnoip提高组试水然后省二滚粗的悲惨经历... 往事不堪回首. 所以说考场上真的有debuffdebuffdebuff啊!!!虽然当时我也不会权值线段树 这道 ...
- poj-3177(并查集+双联通分量+Tarjan算法)
题目链接:传送门 思路: 题目要将使每一对草场之间都有至少两条相互分离的路径,所以转化为(一个有桥的连通图至少加几条边才能变为双联通图?) 先求出所有的桥的个数,同时将不同区块收缩成一个点(利用并查集 ...
- java的Scanner获取输入内容
//导入 scanner的包 import java.util.Scanner; Scanner scanner = new Scanner(System.in); System.out.printl ...
- hdu6444 2018中国大学生程序设计竞赛 - 网络选拔赛 1007 Neko's loop
Neko's loop Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total S ...
- dj 模型层orm-1
ORM简介 MVC或者MVC框架中包括一个重要的部分,就是ORM,它实现了数据模型与数据库的解耦,即数据模型的设计不需要依赖于特定的数据库,通过简单的配置就可以轻松更换数据库,这极大的减轻了开发人员的 ...
- linux 定时器 定时执行php
输入命令: crontab -e 添加定时命令 每隔一分钟执行一次php //复制一下命令即可. */1 * * * * /usr/bin/curl -o /home/logs/temp.lo ...
- 锋利的jQuery(第二版)学习总结
通过对<锋利的jQuery>(第二版)一书的学习,发现此书讲解通俗易懂,是学习jQuery的一本很好的指导书,特作如下总结. 此书主要讲解了jQuery的常用操作,包括认识jQuery,j ...
- 好文推荐系列-------(5)js模块化编程
本文主要来源于阮一峰的<Javascript模块化编程>系列文章整合,原文地址:http://www.ruanyifeng.com/blog/2012/10/javascript_modu ...
- C#系列之{流和序列化}
不论何种类型的文件都可以表示为一个字节数组.(Byte[]) 一.文件复制 (示例) 首先建立一个类似管道的东西将文件和内存中的程序连接,并将文件按字节发送.为了保存接收到的文件字节,需要创建一个字节 ...
- 差值的再议-Hermite差值
1. 插值法 插值法又称“内插法”,是利用函数f (x)在某区间中已知的若干点的函数值,作出适当的特定函数,在区间的其他点上用这特定函数的值作为函数f (x)的近似值,这种方法称为插值法. 如果这特定 ...