问题 : Decimal integer conversion

时间限制: 1 Sec  内存限制: 128 MB

题目描述

XiaoMing likes mathematics, and he is just learning how to convert numbers between different
bases , but he keeps making errors since he is only 6 years old. Whenever XiaoMing converts a
number to a new base and writes down the result, he always writes one of the digits wrong.
For example , if he converts the number 14 into binary (i.e., base 2), the correct result should be
"1110", but he might instead write down "0110" or "1111". XiaoMing never accidentally adds or
deletes digits, so he might write down a number with a leading digit of " 0" if this is the digit she
gets wrong.
Given XiaoMing 's output when converting a number N into base 2 and base 3, please determine
the correct original value of N (in base 10). (N<=10^10)
You can assume N is at most 1 billion, and that there is a unique solution for N.

输入

The first line of the input contains one integers T, which is the nember of test cases (1<=T<=8)
Each test case specifies:
* Line 1: The base-2 representation of N , with one digit written incorrectly.
* Line 2: The base-3 representation of N , with one digit written incorrectly.

输出

For each test case generate a single line containing a single integer ,  the correct value of N

样例输入

1
1010
212

样例输出

14

解题思路

水题,直接暴力,把所有的情况都跑一遍就可以了。

 #include <stdio.h>
 #include <string.h>
 int main()
 {
     int t, A, B, lena, lenb, temp;
     ], b[];
     scanf("%d%*c", &t);
     while (t--)
     {
         temp = ;
         scanf("%s%s", a, b);
         lena = strlen(a);
         lenb = strlen(b);
         ; i < lena; i++)
         {
             A = ;
             a[i] = (a[i] - ) %  + ';
             ; j < lena; j++)
                 A = A *  + a[j] - ';
             a[i] = (a[i] - ) %  + ';
             ; j < lenb; j++)
             {
                 B = ;
                 b[j] = (b[j] - ) %  + ';
                 ; k < lenb; k++)
                     B = B *  + b[k] - ';
                 if (A == B)
                 {
                     temp = ;
                     break;
                 }
                 B = ;
                 b[j] = (b[j] - ) %  + ';
                 b[j] = (b[j] - ) %  + ';
                 ; k < lenb; k++)
                     B = B *  + b[k] - ';
                 if (A == B)
                 {
                     temp = ;
                     break;
                 }
                 b[j] = (b[j] - ) %  + ';
             }
             if (temp)
                 break;
         }
         printf("%d\n", A);
     }
     ;
 }

Decimal integer conversion的更多相关文章

  1. NYOJ 1277Decimal integer conversion (第九届河南省省赛)

    XiaoMing likes mathematics, and heis just learning how to convert numbers between different bases , ...

  2. log4j:ERROR Category option " 1 " not a decimal integer.错误解决

    log4j.properties 的配置文件中: log4j.appender.stdout.layout.ConversionPattern =  %d{ABSOLUTE} %5p %c{ 1 }: ...

  3. 每天一套题打卡|河南省第九届ACM/ICPC

    A 表达式求值 表达式求值:可以用递归求解,也可以用栈模拟,考过多次. 类似题目:NYOJ305,NYOJ35 用栈模拟做法: #include <stdio.h> #include &l ...

  4. java.lang.Integer源码浅析

    Integer定义,final不可修改的类 public final class Integer extends Number implements Comparable<Integer> ...

  5. 使用parquet-hadoop.jar包解析hive parquet文件时,遇到FIXED_LEN_BYTE_ARRAY转换为Decimal 以及 INT96转换为timestamp问题

    在使用parquet-hadoop.jar包解析parquet文件时,遇到decimal类型的数据为乱码,具体解决方法如下: 使用parquet-Hadoop.jar解析httpfs服务提供的parq ...

  6. Conversion Specifiers and the Resulting Printed Output

    Conversion Specification Output %a Floating-point number, hexadecimal digits and p-notation (C99). % ...

  7. The integer promotion.

    Usual Arithmetic Conversion: The integer promotions are performed on both operands. Then the followi ...

  8. java的toString()及包装类的实现--Integer重点学习

    1. toString()来源 2. toString()目的 3. toString()实现(JDK8) 1. toString()来源 源于java.lang.Object类,源码如下: /** ...

  9. LeedCode OJ -- String to Integer (atoi)

    点击打开题目链接 题目意思就是自己实现一个atoi函数,也就是将字符串转换成int型. 关于INT_MAX和INT_MIN, 只是在<limits.h>文件中定义的宏..分别是int型可以 ...

随机推荐

  1. 【如何使用jQuery】【jQuery弹出框】【jQuery对div进行操作】【jQuery对class,id,type的操作】【jquery选择器】

    1.如何使用jQuery jQuery是一个快速.简洁的JavaScript框架,是继Prototype之后又一个优秀的JavaScript代码库(或JavaScript框架).jQuery设计的宗旨 ...

  2. mysql 原理 ~ 索引通说

    简介: 来说说索引吧目的:为了加快数据库的数据查找速度,索引应用而生基础知识基本定义  1 遍历 所谓遍历二叉树,就是按一定的规则和顺序走遍二叉树的所有结点,使每一个结点都被访问一次,而且只被访问一次 ...

  3. eclipse快捷键调试总结 -转--快捷键大全

    (1)Ctrl+M --切换窗口的大小(2)Ctrl+Q --跳到最后一次的编辑处(3)F2      ---重命名类名 工程名 --当鼠标放在一个标记处出现Tooltip时候按F2则把鼠标移开时To ...

  4. Spring boot中普通工具类不能使用@Value注入yml文件中的自定义参数的问题

    在写一个工具类的时候,因为要用到yml中的自定义参数,使用@Value发现值不能正常注入,都显示为null: yml文件中的自定义格式 调用工具类的时候不能new的方式 要使用@Autowired的方 ...

  5. linux中如何使用终端裁剪图片?

    1,首先要安装支持图片裁剪的包: sudo apt-get install imagemagick 需要的话可以update一下, 2,在图片所在位置打开终端,我的我的截图叫screenshot.pn ...

  6. nginx 模块配置

    第一个 当前活跃的连接数 nginx握手的数 连接数 总的请求数

  7. 记一次手动SQL注入

    1.检测到可能存在注入漏洞的url 最常用的 ' ,and 1=1 ,and 1=2 http://www.xxx.com/subcat.php?id=1 2.判断字段个数 http://www.xx ...

  8. 论文笔记:Rich feature hierarchies for accurate object detection and semantic segmentation

    在上计算机视觉这门课的时候,老师曾经留过一个作业:识别一张 A4 纸上的手写数字.按照传统的做法,这种手写体或者验证码识别的项目,都是按照定位+分割+识别的套路.但凡上网搜一下,就能找到一堆识别的教程 ...

  9. 【php】下载站系统Simple Down v5.5.1 xss跨站漏洞分析

    author:zzzhhh 一.        跨站漏洞 利用方法1,直接在搜索框处搜索<script>alert(/xss/)</script>//',再次刷新,跨站语句将被 ...

  10. web前端之性能

    1.避免布局抖动 function resizeAllParagraphsToMatchBlockWidth() { // Puts the browser into a read-write-rea ...