问题 : 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. 第一章 Android系统的编译和移植实例

    第一章 Android系统的编译和移植实例 这一章节主要介绍了Android系统的编译和移植技术,作为建立在Linux内核的基础上的Android操作系统,它的编译和移植不论在过程还是技术方面都和嵌入 ...

  2. Python笔记(三)继承和多态、动态语言

    一.继承 先定义一个A类 class A(object): def fun(self): print "Run A fun()" 在定义一个B类 class B(A): pass ...

  3. 为什么HTTPS比HTTP安全,以及两者的优缺点

    一.HTTPS简介 HTTPS协议的主要作用可以分为两种:一种是建立一个信息安全通道,来保证数据传输的安全:另一种就是确认网站的真实性. HTTP协议传输的数据都是未加密的,也就是明文的,因此使用HT ...

  4. Android热更新技术——Tinker、nuwa、AndFix、Dexposed

    一.热修复技术作用 线上app BUG紧急修复,不重新发版,不重新安装,在线远程修复问题 二.局限性与适用场景 补丁只能针对单一客户端版本,随着版本差异变大补丁体积也会增大: 补丁不能支持所有的修改, ...

  5. python第七天,dict

    在python里边创建字典的方法有如下几种: >>> dict1= dict(((),(),(),(),())) >>> print(dict1) {, , , , ...

  6. [转]python3之模块psutil系统性能信息

    转自:https://www.cnblogs.com/zhangxinqi/p/9106265.html 阅读目录 1.psutil模块安装 2.获取CPU信息 3.内存信息 4.磁盘信息 5.网络信 ...

  7. LwIP Application Developers Manual5---高层协议之DNS

    1.前言 lwIP提供一个基本的DNS客户端(1.3.0后引进),通过使用DNS(Domain Name System)协议来允许应用程序解决主机名到地址的转换. 在文件lwipopts.h里面定义L ...

  8. Go语言模拟实现简单的区块链

    一.创建项目 按照Go语言最佳实践的思路, 在工作空间下的src目录下创建 github.com/hangzhou-huxin/blokcchain目录作为我们的项目目录,然后用GoLand工具选中这 ...

  9. mysql使用group_by

    GROUP BY必须得配合聚合函数来用,分组之后你可以计数(COUNT),求和(SUM),求平均数(AVG)等 常用聚合函数 count() 计数 sum() 求和 avg() 平均数 max() 最 ...

  10. 一道搜索题【2013 noip提高组 DAY2 t3】华容道

    这篇不多说,具体的解释都在程序里 题目描述 [问题描述] 小 B 最近迷上了华容道,可是他总是要花很长的时间才能完成一次.于是,他想到用编程来完成华容道:给定一种局面, 华容道是否根本就无法完成,如果 ...