这里有个讲解 string 用法非常详细的博文:https://www.byvoid.com/zhs/blog/cpp-string

题目意思很简单啦,就是找回文

使用string可以高速A过

Source code:

/*
ID: wushuai2
PROG: palsquare
LANG: C++
*/
//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <stack>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#define ll long long
#define Max(a,b) (((a) > (b)) ? (a) : (b))
#define Min(a,b) (((a) < (b)) ? (a) : (b))
#define Abs(x) (((x) > 0) ? (x) : (-(x))) using namespace std;
const int INF = 0x3f3f3f3f; string solve(int base, int n){
string ss;
while(n){
if(n % base > ){
ss.push_back(n % base - + 'A');
} else{
ss.push_back(n % base + '');
}
n /= base;
}
reverse(ss.begin(), ss.end());
return ss;
} bool judge(string ss){
string pp = ss;
reverse(ss.begin(), ss.end());
if(ss.compare(pp) == ){
return true;
}
return false;
} int main() {
ofstream fout ("palsquare.out");
ifstream fin ("palsquare.in");
int base;
fin >> base;
for(int i = ; i <= ; ++i){
if(judge(solve(base, i * i))){
fout << solve(base, i) << ' ' << solve(base, i * i) << endl;
} } return ;
}

USACO Palindromic Squares 【STL__string_的应用】的更多相关文章

  1. 洛谷P1206 [USACO1.2]回文平方数 Palindromic Squares

    P1206 [USACO1.2]回文平方数 Palindromic Squares 271通过 501提交 题目提供者该用户不存在 标签USACO 难度普及- 提交  讨论  题解 最新讨论 暂时没有 ...

  2. 洛谷 P1206 [USACO1.2]回文平方数 Palindromic Squares

    P1206 [USACO1.2]回文平方数 Palindromic Squares 题目描述 回文数是指从左向右念和从右向左念都一样的数.如12321就是一个典型的回文数. 给定一个进制B(2< ...

  3. Palindromic Squares 回文平方数

    1.2.4 Palindromic Squares 回文平方数 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 139  Solved: 66[Submit ...

  4. 【USACO 1.2】Palindromic Squares

    进制转换,然后判断是否是回文 /******************************************* TASK: palsquare LANG: C++ Created Time: ...

  5. USACO Section 1.2 Palindromic Squares 解题报告

    题目 题目描述 输入一个基数B,现在要从1到300之间找出一些符合要求的数字N.如果N的平方转换成B进制数之后是一个回文串,那么N就符合要求.我们将N转换成B进制数输出,然后再将N的平方转换成B进制数 ...

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

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

  7. USACO 1.2 Palindromic Squares (进制转换,回文)

    /* ID:twd30651 PROG:palsquare LANG:C++ */ #include<iostream> #include<fstream> #include& ...

  8. [Swust OJ 797]--Palindromic Squares(回文数水题)

    题目链接:http://acm.swust.edu.cn/problem/797/ Time limit(ms): 1000 Memory limit(kb): 10000   Description ...

  9. Palindromic Squares

    链接 分析:求出b进制以后在判是否为回文 /* ID:wanghan PROB:palsquare LANG:C++ */ #include "iostream" #include ...

随机推荐

  1. Android UiAutomator 自动化测试环境搭建---新手1

    1.首先需要准备的工具有 1.java jdk 2. android开发工具 adt 3.ant 安装包(如果下载adt里面有) 2.首先安装java环境,jdk这个百度就可以了. 3.android ...

  2. 定时每天备份mysql

    http://blog.csdn.net/panning_hu/article/details/9210001 Spring MVC Spring中MVC框架的底层实现 http://blog.csd ...

  3. ZYB's Premutation(有逆序数输出原序列,线段树)

    ZYB's Premutation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Othe ...

  4. asp.NET配置

    添加用户 1.选择创建用户   2 可以使用网站管理工具来管理应用程序的所有安全设置.可以设置用户和密码(身份验证),可以创建角色(用户组),还可以创建权限(用于控制对应用程序各个部分的访问的规则). ...

  5. Visual Studio warning MSB3270:There was a mismatch between the processor architecture of the project being built "MSIL"

    Problem: There was a mismatch between the processor architecture of the project being built "MS ...

  6. Delete website with command.

    1.AppCmd.exe 2.http://www.windowsnetworking.com/articles-tutorials/windows-server-2008/Configuring-I ...

  7. 【监控】使用probe对tomcat服务进行监控

    1.运行环境(博主本地) JDK:jdk1.6 Tomcat:tomcat7 OS:Windows10 2.下载 点击下载 3.安装运行 1.解压,将probe文件夹复制放进tomcat里面的weba ...

  8. 【前端】使用weinre对手机、微信浏览器页面调试

    官方网站:http://people.apache.org/~pmuellr/weinre-docs/latest/ windows下安装以及使用: 1.安装nodejs 下载nodejs引擎,32b ...

  9. 关于MyEclipse启动时的插件启动(Maven4MyEclipse)

    在myEclipse的应用中有许多插件在开发的时候都用不到,那么,这些插件在启动myEclipse的时候一起启动的越少越好了 Maven4Myeclipse update 每当启动myEclipse的 ...

  10. JPEG概述和头分析(C源码)

    原创文章,转载请注明:JPEG概述和头分析(C源码)  By Lucio.Yang 部分内容来自:w285868925,JPEG压缩标准 1.JPEG概述 JPEG是一个压缩标准,又可分为标准 JPE ...