生词以及在文中意思

forward 向前地  backward 向后地  palindromic 回文的  base 基数(如十进制的10 和二进制的2)  numeral system 数制  decimal system 十进制

notation 记法

这题并不是单纯的进制转换。而是要求输入n和b,将n转换为a0*b^0+a1*b^1+......+ak*b^k的和的形式。再对a0,a1,.....,ak进行判断回文串。

import java.util.ArrayList;
import java.util.Scanner; public class Main { public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
if(n==0) {
System.out.println("Yes");
System.out.print("0");
return;
}
ArrayList<String> l=new ArrayList<String>();
while(n!=0) {
l.add(Integer.toString(n%m));
n/=m;
}
boolean IsTrue=true;
for(int i=0;i<l.size()/2;i++) {
if(!(l.get(i).equals(l.get(l.size()-1-i)))) {
IsTrue=false;
break;
}
}
if(IsTrue) {
System.out.println("Yes"); }
else {
System.out.println("No");
}
System.out.print(l.get(l.size()-1));
for(int i=l.size()-2;i>=0;i--) {
System.out.print(" "+l.get(i));
}
} }

1019. General Palindromic Number (20)的更多相关文章

  1. PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...

  2. 1019 General Palindromic Number (20)(20 point(s))

    problem A number that will be the same when it is written forwards or backwards is known as a Palind ...

  3. PAT Advanced 1019 General Palindromic Number (20 分)

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...

  4. PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) (进制转换,回文数)

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...

  5. 1019 General Palindromic Number (20 分)

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...

  6. PAT (Advanced Level) 1019. General Palindromic Number (20)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  7. PAT甲题题解-1019. General Palindromic Number (20)-又是水题一枚

    n转化为b进制的格式,问你该格式是否为回文数字(即正着写和倒着写一样)输出Yes或者No并且输出该格式又是水题... #include <iostream> #include <cs ...

  8. 【PAT甲级】1019 General Palindromic Number (20 分)

    题意: 输入两个正整数n和b(n<=1e9,2<=b<=1e9),分别表示数字的大小和进制大小,求在b进制下n是否是一个回文串,输出“Yes”or“No”,并将数字n在b进制下打印出 ...

  9. PAT 1019 General Palindromic Number[简单]

    1019 General Palindromic Number (20)(20 分) A number that will be the same when it is written forward ...

随机推荐

  1. Vue-admin工作整理(十): Vuex-Actions(模拟接口请求实现组件字段更新)

    思路:通过提交一个 mutation,而不是直接变更状态,它可以包括异步操作,通过请求接口,定义一个方法,第一个参数为对象,在里面能够提取到一些东西,比如:commit,这是一个方法,调用这个comm ...

  2. SSH无法连接到服务器

    SSH服务器会无法连接,有时候并不是密码的问题,可能由于你上次改了密码(就算改成跟上次一样也是一个效果)导致家目录下的known_hosts(/root/.ssh/known_hosts)不一样了并且 ...

  3. 学习笔记77—Iphone集

    ****************************************************** 如有谬误,请联系指正.转载请注明出处. 联系方式: e-mail: heyi9069@gm ...

  4. 2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)

    A Drawing Borders 很多构造方法,下图可能是最简单的了 代码: #include<bits/stdc++.h> using namespace std; ; struct ...

  5. 菜鸟脱壳之脱壳的基础知识(六)——手动查找IAT和修复Dump的程序

    前面讲了如何寻找OEP和脱壳,有的时候,Dump出来的时候不能正常运行,是因为还有一个输入表没有进行处理,一些加密壳会在IAT加密上面大做文章,用HOOK - API的外壳地址来代替真是的IAT的地址 ...

  6. Goroutine通信与thread in java间的通信

    // This file contains the implementation of Go channels. // Invariants: //  At least one of c.sendq ...

  7. Wincc报表+Listview使用

    listview在Wincc中可以作为显示的控件,对于列表表头的定义如下所示: list的命名,点击属性,在对象名称中对其定义: 有了listview的定义,就可以使用VBS对其表头的定义.具体代码如 ...

  8. 合并两个 Lambda 表达式

    概述 在开发工作中,有些时候需要对一些增删改查进行封装(用 Lambda 表达式来筛选数据),但是又有一部分条件总是相同的,对于相同的部分可以直接写到方法里,而不同的部分作为参数传进去. 定义扩展方法 ...

  9. [luogu P3065] [USACO12DEC]第一!First!

    [luogu P3065] [USACO12DEC]第一!First! 题目描述 Bessie has been playing with strings again. She found that ...

  10. 简单测试 Kotlin native 性能

    准备 一直使用kotlin JVM平台开发服务器的应用,最近想试试看 Kotlin native的性能. 我使用的是 kotlin native 1.3.21,要使用他非常的简单,下载最新的 IDEA ...