dualpal解题报告 —— icedream61 博客园(转载请注明出处)
------------------------------------------------------------------------------------------------------------------------------------------------
【题目】
  给出N和S,找出大于S的前N个双回文数。
  双回文数定义:在二进制至十进制中的两种(或两种以上)进制下是回文数。
【数据范围】
  1<=N<=15
  0<S<10000
  本题不需要使用大于4字节的整型变量
【输入样例】
  3 25
【输出样例】
  26
  27
  28
------------------------------------------------------------------------------------------------------------------------------------------------
【分析】
  没难度。
------------------------------------------------------------------------------------------------------------------------------------------------
【总结】
  很可惜,又不是一遍AC。(在main中,“--N”一句忘了写了。)

------------------------------------------------------------------------------------------------------------------------------------------------

【代码】

 /*
ID: icedrea1
PROB: dualpal
LANG: C++
*/ #include <iostream>
#include <fstream>
using namespace std; int N,S; char to(int x) { return x-+''; }
string change(int x,int B)
{
string num;
while(x) { num=to(x%B)+num; x/=B; }
return num;
}
bool isPal(string num)
{
for(int i=;i!=num.size();++i)
if(num[i]!=num[num.size()--i]) return false;
return true;
} int main()
{
ifstream in("dualpal.in");
ofstream out("dualpal.out"); int cnt;
in>>N>>S;
while(N)
{
cout<<"N="<<N<<endl;
++S; cnt=;
for(int B=;B<=;++B) cnt+=isPal(change(S,B));
if(cnt>=) { out<<S<<endl; --N; }
} in.close();
out.close();
return ;
}

USACO Section1.2 Dual Palindromes 解题报告的更多相关文章

  1. USACO Section1.5 Prime Palindromes 解题报告

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

  2. USACO Section1.5 Superprime Rib 解题报告

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

  3. USACO Section1.5 Number Triangles 解题报告

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

  4. USACO Section1.4 Arithmetic Progressions 解题报告

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

  5. USACO Section1.3 Combination Lock 解题报告

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

  6. USACO Section1.3 Prime Cryptarithm 解题报告

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

  7. USACO Section1.3 Barn Repair 解题报告

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

  8. USACO Section1.3 Mixing Milk 解题报告

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

  9. USACO Section1.2 Palindromic Squares 解题报告

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

随机推荐

  1. Docker build 安装报错, Could not open requirments file: [Errno 2] No such file or directory:'requirements.txt'

    docker安装教程 https://docs.docker.com/get-started/part2/#build-the-app 相关帖子 https://stackoverflow.com/q ...

  2. graphql 后台服务项目架构(一)

    基础知识 简而言之,GraphQL 是一种描述如何请求数据的语法,通常用于客户端向服务器请求数据.GraphQL 有三个主要特点: 允许客户端精确指定所需数据. 可以更容易地从多个数据源聚合数据. 使 ...

  3. BZOJ 4679/Hdu5331 Simple Problem LCT or 树链剖分

    4679: Hdu5331 Simple Problem 题意: 考场上,看到这道题就让我想起BZOJ4712洪水.然后思路就被带着飞起了,完全没去考虑一条链的情况,于是GG. 解法:先考虑一条链的做 ...

  4. 入坑Ubuntu手记-系统安装和简单配置

    对于开发者而言,Linux的环境帮助是非常大的.同样的,Linux对很多Windows下的软件,尤其是游戏不支持,这也是一个非常重要的生产力的因素.嗯…我可能就是为了控制自己少玩游戏,直接上一个Ubu ...

  5. 【转载】#324 - A Generic Class Can Have More than One Type Parameter

    A generic class includes one or more type parameters that will be substituted with actual types when ...

  6. iis 7 操作 .net

    下面说一下.NET对IIS7操作.IIS7的操作和IIS5/6(using system.DirectoryServices;使用类DirectoryEntry )有很大的不同,在IIS7里增加了 M ...

  7. 原生Servlet 上传文件

    依赖jar <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons ...

  8. Linux查看CPU和内存使用情况[转]

    在系统维护的过程中,随时可能有需要查看 CPU 使用率,并根据相应信息分析系统状况的需要.在 CentOS 中,可以通过 top 命令来查看 CPU 使用状况.运行 top 命令后,CPU 使用状态会 ...

  9. 简单介绍Spring是什么?

    对于面试者回答什么是Spring,这个问题占6分分值,分值点分布:1.Spring的核心是一个轻量级(Lightweight)的容器(Container).2.Spring是实现IoC(Inversi ...

  10. CentOS中配置php环境

    1.安装apache: yum install httpd httpd-devel   2.安装mysql: yum install mysql mysql-server   3.安装php: yum ...