这里有个讲解 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. 编写带参数decorator

    无参的@log装饰器: def log(f): def fn(x): print 'call ' + f.__name__ + '()...' return f(x) return fn 发现对于被装 ...

  2. [LeetCode]题解(python):105-Construct Binary Tree from Preorder and Inorder Traversal

    题目来源: https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ 题意分析: ...

  3. 02-C语言执行过程

    目录: 一.MACOS系统操作 二.C语言的使用方式 三.编码 四.编译 五.运行 六.分析第一个C程序 七.预处理指令#include 八.完整执行过程 回到顶部 一.MACOS系统操作 操作计算机 ...

  4. 整理网站优化(SEO)的方案

    首先,我们来确定一下seo方案的定义是什么,所谓seo方案是指针对于某个网站,在完成了解熟悉的情况下,结合自身的一套seo优化方法来制定完成符合这个网站seo推广思路和策略.接下来就了解一下新手seo ...

  5. 电脑cmos是什么?和bois的区别?

    很多人都分不清电脑cmos和bois区别,有人一会儿说什么bois设置,有人一会儿说cmos设置.而看起来这两个又似乎差不多,本文将用最简单的白话文告诉各位,什么是cmos,以及cmos和bois的的 ...

  6. 64位linux下安装oracle10 64位 遇到 :ins_ctx.mk ;ins_emdb.mk

    http://blog.csdn.net/bamuta/article/details/10523835 http://www.cnblogs.com/kerrycode/p/3519446.html ...

  7. spring boot 下 500 404 错误页面处理

    spring boot 作为微服务的便捷框架,在错误页面处理上也有一些新的处理,不同于之前的spring mvc 500的页面处理是比较简单的,用java config或者xml的形式,定义如下的be ...

  8. 笔试题引出float数据的存储方式的深究

    笔试题: #include <iostream>#include <stdio.h>#include <string.h>#include <conio.h& ...

  9. hdu1715 大菲波数

    转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1715 Problem ...

  10. Ext.MessageBox.Show使用Progress

    在此之前,先添加引用:以下引用方式仅供参考:由于我的extjs文件夹放在script文件夹下 <link href="~/Scripts/extjs/resources/ext-the ...