问题 : 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. python - pymysql模块

    pymsql 模块 基本应用介绍: # 安装模块 pip install PyMySql # 导入模块 import pymysql # 配置连接信息 config = { 'host':'127.0 ...

  2. Javascript - ExtJs - TreePanel组件

    TreePanel组件(Ext.tree.TreePanel)logogram:Ext.tree.Panel | xtype:treepanel 树与节点 树面板组件的根是源头,从根上拓展出其它的子节 ...

  3. [转] python运行时内存分析工具meliae

    转自:https://my.oschina.net/markco/blog/601773 利用meliae来监控python进程的内存占用情况 meliae是一个python进程内存占用监控.分析工具 ...

  4. caffe调试

    这里说一下关于如何进行Caffe的调试: 参考:https://blog.csdn.net/tsyccnh/article/details/51679121 简要说一下步骤: (1)首先对libcaf ...

  5. Webpack2 中的 NamedModulesPlugin 与 HashedModuleIdsPlugin

    要讨论Webpack 2中新增的这两个plugin的功能,还要先从使用Webpack打包的项目的前端资源缓存方案说起. 通常在使用了Webpack的项目中我们会使用CommonsChunkPlugin ...

  6. CreateDialog和DialogBox

    原文地址:https://blog.csdn.net/aikker/article/details/5631412 INT_PTR DialogBox(          HINSTANCE hIns ...

  7. zookeeper权限问题

    对cdrwa的说明如上,网上一些博客乱写误导 参考链接:http://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html 这是在使用zk ...

  8. java压缩图片质量

    使用了工具thumbnailator,据说thumbnailator是一个非常好的图片开源工具,使用起来很方便.不过没仔细看过,我只是需要压缩图片,让其占用空间变小而已.使用maven引入jar包 & ...

  9. js 测试性能

    console.time('querySelector');for(var i=0; i<1000; i++){document.querySelector('body');}console.t ...

  10. chrome:禁用缓存

    F12->Network 非常好用!!!!!!!!!!