题意

题解

枚举每一个可能的二进制数。扔到一个map里

再枚举每一个可能的三进制数看map有没有就行了

反正就是很水

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;
map<long long,bool>ma;
char s1[],s2[];
long long ksm(long long x,long long b){
long long tmp=;
while(b){
if(b&){
tmp*=x;
}
b>>=;
x=x*x;
}
return tmp;
}
void work(char s[]){
long long len=strlen(s+);
long long tmp=;
for(long long i=;i<=len;i++){
tmp=tmp*+s[i]-'';
}
for(long long i=;i<=len;i++){
long long ans=tmp+(((s[i]-'')^)-(s[i]-''))*(<<len-i);
ma[ans]=;
}
}
void work1(char s[]){
long long len=strlen(s+);
long long tmp=;
for(long long i=;i<=len;i++){
tmp=tmp*+s[i]-'';
}
for(long long i=;i<=len;i++){
for(long long j=;j<=;j++){
if(j==s[i]-'')continue;
long long ans=tmp+(j-(s[i]-''))*ksm(,len-i);
if(ma[ans]==){
printf("%lld",ans);
return ;
}
}
}
}
int main(){
scanf("%s",s1+);
scanf("%s",s2+);
work(s1);
work1(s2);
return ;
}

luoguP1555 尴尬的数字(暴力+map)的更多相关文章

  1. 洛谷 P1555 尴尬的数字

    P1555 尴尬的数字 题目背景 Bessie刚刚学会了不同进制数之间的转换,但是她总是犯错误,因为她的两个前蹄不能轻松的握住钢笔. 题目描述 每当Bessie将一个数转换成新的进制时,她总会写错一位 ...

  2. hdu1172猜数字(暴力枚举)

    猜数字 Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  3. bzoj 2761: [JLOI2011]不重复数字 (map||Treap)

    链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2761 思路: map标记 实现代码: #include<bits/stdc++.h&g ...

  4. hdu 1004 颜色与数字(map水题)

    Sample Input5 //Tgreenredblueredred 统计颜色的次数 输出最多的颜色3pinkorangepink0 Sample Outputred pink # include ...

  5. codeforces 633D D. Fibonacci-ish(dfs+暴力+map)

    D. Fibonacci-ish time limit per test 3 seconds memory limit per test 512 megabytes input standard in ...

  6. CF1005C Summarize to the Power of Two 暴力 map

    Summarize to the Power of Two time limit per test 3 seconds memory limit per test 256 megabytes inpu ...

  7. [BZOJ2761][JLOI2011]不重复数字 暴力

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2761 直接暴力. #include<cstdio> #include<c ...

  8. uoj98未来程序改 纯暴力不要想了

    暴力模拟A了,数据还是良(shui)心(shui)的 90分的地方卡了半天最后发现一个局部变量被我手抖写到全局去了,,, 心碎*∞ 没什么好解释的,其实只要写完表达式求值(带函数和变量的),然后处理一 ...

  9. [ACM_水题] ZOJ 3706 [Break Standard Weight 砝码拆分,可称质量种类,暴力]

    The balance was the first mass measuring instrument invented. In its traditional form, it consists o ...

随机推荐

  1. Smalltalk

    Smalltalk is an object-oriented, dynamically typed, reflective programming language. Smalltalk was o ...

  2. 【HiJ1m】在NOIP2017前写过的有用的东西汇总

    http://www.cnblogs.com/Elfish/p/7544623.html 高级树状数组 http://www.cnblogs.com/Elfish/p/7554420.html BST ...

  3. HDU 2078 选课时间( 水题 )

    链接:传送门 思路:水题略 /************************************************************************* > File N ...

  4. freeswitch 注册错误408 - Request Timeout

    1.网络不通(可能虚拟机没打开网络) 2.防火墙没有过滤端口号(关闭防火墙) 3.IP地址错误

  5. myeclipse的git插件安装

    首先需要一个myeclies的Git插件EGit 点击下载5.0.1 官方网站

  6. Android开发进度04

    1,今日:目标:实现登录和注册功能 2,昨天:完成登录和注册的界面以及后台数据库的操作 3,收获:会使用SQlite数据库的操作语句 4,问题:登录时出现问题(登录不上去)

  7. Hash大法

    内容参考<算法竞赛进阶指南> 之前集训的时候听老师讲过,字符串题目中,hash一般不是正解,但是是一个优秀的暴力,可以拿比较多的部分分. hash涉及内容很多,这里只讨论字符串hash 可 ...

  8. Java并发和多线程3:线程调度和有条件取消调度

    在第1篇中"并发框架基本示例",提到了Executors和ThreadPool.其中,还有个"定时调度"的方法,Executors.newScheduledTh ...

  9. JVM运行原理详解

    1.JVM简析:      作为一名Java使用者,掌握JVM的体系结构也是很有必要的.      说起Java,我们首先想到的是Java编程语言,然而事实上,Java是一种技术,它由四方面组成:Ja ...

  10. C/C++ Quick Sort Algorithm

    本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50255069 快速排序算法,由C.A. ...