Judge Info

  • Memory Limit: 32768KB
  • Case Time Limit: 10000MS
  • Time Limit: 10000MS
  • Judger: Number Only Judger

Description

A number that reads the same from right to left as when read from left to right is called a palindrome. The number 12321 is a palindrome; the number 77778 is not. Of course, palindromes have neither leading nor trailing zeroes, so 0220 is not a palindrome.

The number 21 (base 10) is not palindrome in base 10, but the number 21 (base 10) is, in fact, a palindrome in base 2 (10101).

Write a program that reads two numbers (expressed in base 10):

  • N (1 <= N <= 15)
  • S (0 < S < 10000)

and then finds and prints (in base 10) the first N numbers strictly greater than S that are palindromic when written in two or more number bases (2 <= base <= 10). Solutions to this problem do not require manipulating integers larger than the standard 32 bits.

Input

The first line of input contains , the number of test cases.

For each test case, there is a single line with space separated integers N and S.

Output

For each test case output N lines, each with a base 10 number that is palindromic when expressed in at least two of the bases 2..10. The numbers should be listed in order from smallest to largest.

Sample Input

2
3 25
1 25

Sample Output

26
27
28
26

解题思路:找两个1~10进制之间的回文数字,当时看成找1个回文数字就可以通过,所以导致好久才AC,看题失误!

 #include <stdio.h>
#include <string.h> char A[];
int main()
{
int num,r,i,n,j,t,k,ke,mark,len,last,flag;
scanf("%d",&n);
while(n--){
scanf("%d %d",&last, &k);
while(last--){
++k; flag=;
for(r=;r<=;r++){
i=;
num=k;
mark=; while(num>){
t=num%r;
A[i]= t+'';
++i;
num/=r;
}
len = i-; for(i=,j=len;i<=j;i++,j--){
if(A[i]!=A[j])
mark=;
} if(mark==){
flag++;
}
if(flag==){
printf("%d\n", k);
break;
}
}
if(flag!=)
++last;
}
}
return ;
}

SZU:B54 Dual Palindromes的更多相关文章

  1. Dual Palindromes

    Dual PalindromesMario Cruz (Colombia) & Hugo Rickeboer (Argentina) A number that reads the same ...

  2. 洛谷P1207 [USACO1.2]双重回文数 Dual Palindromes

    P1207 [USACO1.2]双重回文数 Dual Palindromes 291通过 462提交 题目提供者该用户不存在 标签USACO 难度普及- 提交  讨论  题解 最新讨论 暂时没有讨论 ...

  3. 洛谷 P1207 [USACO1.2]双重回文数 Dual Palindromes

    P1207 [USACO1.2]双重回文数 Dual Palindromes 题目描述 如果一个数从左往右读和从右往左读都是一样,那么这个数就叫做“回文数”.例如,12321就是一个回文数,而7777 ...

  4. luogu1207双重回文数[usaco1.2]Dual Palindromes

    题目描述 如果一个数从左往右读和从右往左读都是一样,那么这个数就叫做“回文数”.例如,12321就是一个回文数,而77778就不是.当然,回文数的首和尾都应是非零的,因此0220就不是回文数. 事实上 ...

  5. USACO Section 1.2 Dual Palindromes 解题报告

    题目 题目描述 有一些数(如 21),在十进制时不是回文数,但在其它进制(如二进制时为 10101)时就是回文数. 编一个程序,从文件读入两个十进制数N.S.然后找出前 N 个满足大于 S 且在两种以 ...

  6. USACO Section1.2 Dual Palindromes 解题报告

    dualpal解题报告 —— icedream61 博客园(转载请注明出处)-------------------------------------------------------------- ...

  7. USACO Chapter 1 解题总结

    USACO Chapter 1 解题总结 1.1.1 Your Ride Is Here 基本字符串操作,无压力. 1.1.2 Greedy Gift Givers 基础模拟题,弄明白题意,不怕麻烦, ...

  8. USACO chapter1

    几天时间就把USACO chapter1重新做了一遍,发现了自己以前许多的不足.蒽,现在的程序明显比以前干净很多,而且效率也提高了许多.继续努力吧,好好的提高自己.这一章主要还是基本功的训练,没多少的 ...

  9. Luogu USACO Training 刷水记录

    开个坑记录一下刷USACO的Training的记录 可能会随时弃坑 只有代码和做法简述 可能没有做法简述 [USACO1.1]你的飞碟在这儿Your Ride Is He… 模拟,细节已忘 #incl ...

随机推荐

  1. iBatis多表查询

    <typeAlias alias="Product" type="com.shopping.entity.Product"/> <typeAl ...

  2. IOS 警告 收集

    Semantic Warnings Warning Message -WCFString-literal input conversion stopped due to an input byte t ...

  3. Matlab splinetx

    function v = splinetx(x,y,u) %SPLINETX Textbook spline function. % v = splinetx(x,y,u) finds the pie ...

  4. linux_vim_最佳快捷键

    如何使用vi文本编辑器     vi由比尔·乔伊(Bill Joy)撰写,所有UNIX like均默认安装此文本编辑器.详细简介请点击维基中文. 1.首先复制一个文件到/tmp目录(本例中为复制根目录 ...

  5. Android 自己的自动化测试(5)&lt;robotium&gt;

    大约Android自己的自动化测试UI测试,前出台Android 自己主动化測试(4)<uiautomator>, 在android原生的单元測试框架上,利用uiautomator.jar ...

  6. 【百度地图API】如何制作可拖拽的沿道路测距

    原文:[百度地图API]如何制作可拖拽的沿道路测距 摘要: 地图测距,大家都会,不就map.getDistance麼.可是,这只能测任意两点的直线距离,用途不够实际啊.比如,我想测试北京天安门到北京后 ...

  7. FZU操作系统课程实验 实验一

    实验1 [实验名称]:并发程序设计(实验1) [实验目的]:掌握在程序中创建新进程的方法, 观察并理解多道程序并发运行的现象. [实验原理]:fork():建立子进程.子进程得到父进程地址空间的一个复 ...

  8. Codeforces #180 div2 C Parity Game

    // Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...

  9. NET MVC中使用FluentValidation

    ASP.NET MVC中使用FluentValidation验证实体   1.FluentValidation介绍 FluentValidation是与ASP.NET DataAnnotataion ...

  10. Cocos2d-x学习笔记(14)(更新函数scheduleUpdate、进度计时器CCProgressTo、滚动视图CCScrollView)

    一.scheduleUpdate 1.scheduleUpdate:此函数是CCNode的函数,每一个CCNode仅仅要调用scheduleUpdate更新函数,那么这个CCNode就会响应当前类的u ...