分析:码农题,照这模拟就行,高精度的B进制,注意字符串反转的技巧。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
const int maxn=;
char s[]={'','','','','','','','','','','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
int n; //进制
int vis1[maxn],vis2[maxn];
int ans[maxn];
int main()
{
while(cin>>n)
{
string a,b;
cin>>a;
cin>>b;
memset(vis1,,sizeof(vis1));
memset(vis2,,sizeof(vis2));
int len1=a.length(); //反转第一个串
for(int i=;i<len1/;i++){
char temp=a[i];
a[i]=a[len1--i];
a[len1--i]=temp;
}
for(int i=;i<len1;i++){
int pos;
for(int j=;j<;j++){
if(a[i]==s[j]){
pos=j; break;
}
}
vis1[i]=pos;
}
int len2=b.length(); //反转第二个串
for(int i=;i<len2/;i++){
char tt=b[i];
b[i]=b[len2-i-];
b[len2--i]=tt;
}
for(int i=;i<len2;i++){
int pos;
for(int j=;j<;++j){
if(b[i]==s[j]){
pos=j; break;
}
}
vis2[i]=pos;
}
int mx=max(len1,len2);
int cnt=;
for(int i=;i<mx;i++){
int temp=vis1[i]+vis2[i]+cnt;
if(temp>=n){
cnt=;
ans[i]+=temp%n;
}else{
cnt=;
ans[i]+=temp;
}
}
if(cnt==){
ans[mx]=; ++mx;
}
string ss;
for(int i=;i<mx;i++){
ss+=s[ans[i]];
}
for(int i=;i<mx/;i++){
char yy=ss[i];
ss[i]=ss[mx-i-];
ss[mx-i-]=yy;
}
cout<<ss<<endl;
}
return ;
}

B进制加法(洛谷1604)的更多相关文章

  1. (进制转换 栈)P1143 进制转换 洛谷

    题目描述 请你编一程序实现两种不同进制之间的数据转换. 输入输出格式 输入格式: 共三行,第一行是一个正整数,表示需要转换的数的进制n(2≤n≤16),第二行是一个n进制数,若n>10n> ...

  2. N进制加法

    我是网络公司的一名普通程序员,英文名Steven,发音比较像“师弟”,自从入职培训自我介绍后,大家就称我为“二师弟”,我喜欢看科幻小说,也喜欢做梦,有一次梦到外星球,发现外星人使用的并非10进制/16 ...

  3. hdu2100 26进制加法

    题意:       给你两个26进制数,让你算出他们两个的和. 思路:      水题不解释了,注意这样的数据 AAA AAA 输出A #include<stdio.h> #include ...

  4. XDU 1003 B进制加法(高精度)

    #include<bits/stdc++.h> using namespace std; long long mpow(long long a,long long b) { ; ) ; w ...

  5. 洛谷 P1013 进制位 【搜索 + 进制运算】

    题目描述 著名科学家卢斯为了检查学生对进位制的理解,他给出了如下的一张加法表,表中的字母代表数字. 例如: + L K V E L L K V E K K V E KL V V E KL KK E E ...

  6. noip 1998 洛谷P1013 进制位

    题目描述 著名科学家卢斯为了检查学生对进位制的理解,他给出了如下的一张加法表,表中的字母代表数字. 例如: L K V E L L K V E K K V E KL V V E KL KK E E K ...

  7. 洛谷P1013 进制位

    P1013 进制位 题目描述 著名科学家卢斯为了检查学生对进位制的理解,他给出了如下的一张加法表,表中的字母代表数字. 例如: + L K V E L L K V E K K V E KL V V E ...

  8. [NOIP1998] 提高组 洛谷P1013 进制位

    题目描述 著名科学家卢斯为了检查学生对进位制的理解,他给出了如下的一张加法表,表中的字母代表数字. 例如: L K V E L L K V E K K V E KL V V E KL KK E E K ...

  9. 洛谷 P1013 进制位

    P1013 进制位 题目描述 著名科学家卢斯为了检查学生对进位制的理解,他给出了如下的一张加法表,表中的字母代表数字. 例如: + L K V E L L K V E K K V E KL V V E ...

随机推荐

  1. iperf linux版本移植到android (使用工具链方式不是使用Android.mk)

    由于很多程序是用makefile编译linux应用程序的,如果移植到android就要重新写Android.mk,对于不熟悉这个的人来说,特别麻烦,所以这里介绍只修改makefile就能移植到andr ...

  2. 【单源最短路模板】 poj 2387

    #include <cstdio> #include <iostream> #include <stdlib.h> #include <memory.h> ...

  3. 【多重背包模板】poj 1014

    #include <iostream> #include <stdio.h> #include <cstring> #define INF 100000000 us ...

  4. Too Much Money

    Too Much Money time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  5. JavaScript(1)——变量、函数声明及作用域

    这是我的第一篇博客文章,本人不才,文笔也不好,所以可能写的有点凌乱.有什么不对的地方还望见谅.不过每天进步一小步,总有一天会迈出那一大步.以下内容是我对变量.函数声明及函数表达式.作用域的理解. [变 ...

  6. Android中获取网络数据时的分页加载

    //此实在Fragment中实现的,黄色部分为自动加载,红色部分是需要注意的和手动加载,    蓝色部分是睡眠时间,自我感觉不用写  ,还有就是手动加载时,不知道为什么进去后显示的就是最后一行,求大神 ...

  7. cocos2d-x 3.x 橡皮擦功能

    1.HelloWorldScene.h cocos2d::DrawNode* _eraser; cocos2d::RenderTexture*_renderTexture; 2.HelloWorldS ...

  8. 使用RPM包安装、配置和拆卸MySQL

    通过rpm包安装.配置及卸载mysql的详细过程. 以MySQL-server-4.0.14-0.i386.rpm为例,放在/usr/src目录下 cd /usr/src rpm -ivh MySQL ...

  9. USACO Section 1.3 Combination Lock 解题报告

    题目 题目描述 农夫John的牛从农场逃脱出去了,所以他决定用一个密码锁来把农场的门锁起来,这个密码锁有三个表盘,每个表盘都是环形的,而且上面刻有1~N,现在John设了一个开锁密码,而且这个锁的设计 ...

  10. [JNI] Java 调用 C++ dll

    首先介绍一下JNI吧! JNI 是Java提供的一个用于调用本地接口的接口层,位于Java代码 和 本地代码之间的一层:主要功能是 数据类型的转换,还有就是通过这一层来调用本地代码! 下面就说说Jav ...