luoguP1555 尴尬的数字(暴力+map)
题意

题解
枚举每一个可能的二进制数。扔到一个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)的更多相关文章
- 洛谷 P1555 尴尬的数字
P1555 尴尬的数字 题目背景 Bessie刚刚学会了不同进制数之间的转换,但是她总是犯错误,因为她的两个前蹄不能轻松的握住钢笔. 题目描述 每当Bessie将一个数转换成新的进制时,她总会写错一位 ...
- hdu1172猜数字(暴力枚举)
猜数字 Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- bzoj 2761: [JLOI2011]不重复数字 (map||Treap)
链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2761 思路: map标记 实现代码: #include<bits/stdc++.h&g ...
- hdu 1004 颜色与数字(map水题)
Sample Input5 //Tgreenredblueredred 统计颜色的次数 输出最多的颜色3pinkorangepink0 Sample Outputred pink # include ...
- 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 ...
- 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 ...
- [BZOJ2761][JLOI2011]不重复数字 暴力
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2761 直接暴力. #include<cstdio> #include<c ...
- uoj98未来程序改 纯暴力不要想了
暴力模拟A了,数据还是良(shui)心(shui)的 90分的地方卡了半天最后发现一个局部变量被我手抖写到全局去了,,, 心碎*∞ 没什么好解释的,其实只要写完表达式求值(带函数和变量的),然后处理一 ...
- [ACM_水题] ZOJ 3706 [Break Standard Weight 砝码拆分,可称质量种类,暴力]
The balance was the first mass measuring instrument invented. In its traditional form, it consists o ...
随机推荐
- node——读取文件中的路径问题
前提 当前的js文件叫_dirnameandfilename.js和hello.txt同在G:\node练习文件夹下 还有一个_dirnameandfilename.js文件在i:/文件夹,但是i:/ ...
- 【转】Retina 屏幕下,网页图片的显示兼容
感谢 Apple,带来了 Retina 屏幕的革命,让我们可以在电子显示屏上享受到印刷级的分辨率.由于分辨率的提升,网页中的文字.Flash 和 SVG 内容显示得比原来更加精细,但网页中的图片却变得 ...
- Vue学习之路第四篇:v-html指令
上一篇我们讲解了两种方式,把Vue对象的数据展示在页面上: 1.插值表达式 2.v-text指令 但是如果我们展示的数据包含元素标签或者样式,我们想展示标签或样式所定义的属性作用,该怎么进行渲染,比如 ...
- POJ 1185 炮兵阵地 (状压dp)(棋盘dp)
这题和poj 3254很像,但是更复杂了一些 都属于棋盘里放东西,然后又各种各样的限制,然后求方案或者最大值 (1)上一道题距离要大于1,这道题是大于2.所以判断的时候变成 !(x & (x ...
- [luogu] P3333 [ZJOI2013]丽洁体(贪心)
P3333 [ZJOI2013]丽洁体 题目描述 平时的练习和考试中,我们经常会碰上这样的题:命题人给出一个例句,要我们类比着写句子.这种往往被称为仿写的题,不单单出现在小学生的考试中,也有时会出现在 ...
- 11g,12c Oracle Rac安装
安装 Oracle 12cR1 RAC on Linux 7 本文介绍如何在Oracle Linux 7上安装2节点Oracle 12cR1 Real Application Cluster(RAC) ...
- 什么是PL/SQL,有什么用
1.什么是PL/SQL,有什么用 Procedure Language+SQL PL/SQL是Oracle数据库特有的编程语言. PL/SQL程序是以SQL为基础,引入了 编程语言特点,例如变 ...
- HDU 4324 Contest 3
直接DFS即可 #include <iostream> #include <string.h> #include <algorithm> #include < ...
- node-webkit 主页面和 iframe 页通讯
<html lang="en-US"> <head> <title>Hello World!</title> <style&g ...
- 剑指offer_面试题_从上往下打印二叉树
题目:从上往下打印出二叉树的每一个结点.同一层的结点依照从左到右的顺序打印.比如输入图4.5中的二叉树.则依次打印出8.6.10.5.7.9.11. 8 / \ 6 10 / \ ...