Dual Palindromes
来源:互联网 发布:cydia怎么删除软件 编辑:程序博客网 时间:2024/06/06 14:19
http://train.usaco.org/usacoprob2?a=C2JqJy82RWk&S=dualpal
题目大意:
双重回文:在2---10进制表示下,至少有2种表示为回文数字
输入:N,S
输出:大于S的前N个回文数字
#include <iostream>#include <fstream>using namespace std;string s = "0123456789";string convert(int n, int r) //n(10进制)----> string(r进制) {string c;int d;//余数while(n){d = n%r;c += s[d];n /= r;}return c;}bool isok(string c)//判断回文 {for(int i = 0, j = c.size() - 1; i < j; i++, j--)if(c[i] != c[j]) return false;return true;}int main(){ifstream fin("dualpal.in");ofstream fout("dualpal.out");int a, b, n, m;string c;while(fin >> a >> b){ n = 0;for(int i = b + 1; n < a; i++){m = 0;for(int j = 2; j <= 10; j++){if(isok(convert(i, j))) m++;if(m >= 2) break;}if(m >= 2) {n++;fout << i << endl;}}} return 0;}
1 0
- Dual Palindromes
- dual palindromes
- Dual Palindromes
- Dual Palindromes
- Dual Palindromes
- Dual Palindromes
- Dual Palindromes
- Dual Palindromes
- Dual Palindromes(USACO)
- 1.2.5 Dual Palindromes
- Section 1.2 Dual Palindromes
- [USACO] Dual Palindromes
- USACO 1.2 Dual Palindromes
- 1.2.5 Dual Palindromes
- 1.2 Dual Palindromes
- usaco Dual Palindromes
- USACO:Dual Palindromes
- USACO Dual Palindromes
- iOS 对字符串压缩
- NYOJ 767 因子和
- Android微信支付
- 《VR入门系列教程》之22---GearVR SDK代码剖析
- [疯狂Java]NIO:使用Channel、Charset(字符集)、使用Charset传递CharBuffer
- Dual Palindromes
- [从头学声学] 第208节 汉语的拼音
- 使用exe4j制作java启动程序等候界面
- 【OpenMP】互斥
- 母亲节快到了,和老妈一起烫个发吧!
- python reverse()方法
- POJ 3026 Borg Maze【BFS+最小生成树MST】
- iOS 简单的改变导航栏的背景 几行代码解决
- Oracle 如何修改列的数据类型