生词以及在文中意思

duplication 重复  permutation 排列  property 属性

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
String s=sc.next();
int [] a=new int[s.length()];
for(int i=0;i<s.length();i++) {
a[i]=s.charAt(i)-48;
}
boolean IsTrue=true;
int sum=0;
int [] cnt1=new int[21];
int [] cnt2=new int[21];
int [] result=new int[21];
for(int i=s.length()-1;i>=0;i--) {
int n=s.charAt(i)-48;
cnt1[n]++;
n=2*n+sum;
int m=n%10;
sum=n/10;
result[i]=m;
cnt2[m]++;
}
if(sum!=0) {//如果有进位,把它放在result数组的[s.length()]位置上
IsTrue=false;
result[s.length()]=sum;
cnt2[sum]++;
}
int sum1=0;
int sum2=0;
for(int i=0;i<21;i++) {
if(cnt1[i]!=cnt2[i]) {
IsTrue=false;
}
}
if(IsTrue) {
System.out.println("Yes");
}
else {
System.out.println("No");
}
if(sum==0) {
for(int i=0;i<s.length();i++) {
System.out.print(result[i]);
}
}
else {//如果有进位,先输出放在后面的进位数字
System.out.print(result[s.length()]);
for(int i=0;i<s.length();i++) {
System.out.print(result[i]);
}
}
} }

1023. Have Fun with Numbers (20)的更多相关文章

  1. PAT 甲级 1023 Have Fun with Numbers (20 分)(permutation是全排列题目没读懂)

    1023 Have Fun with Numbers (20 分)   Notice that the number 123456789 is a 9-digit number consisting ...

  2. 1023 Have Fun with Numbers (20 分)

    1023 Have Fun with Numbers (20 分)   Notice that the number 123456789 is a 9-digit number consisting ...

  3. PAT (Advanced Level) Practice 1023 Have Fun with Numbers (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1023 Have Fun with Numbers (20 分) 凌宸1642 题目描述: Notice that the number ...

  4. 1023 Have Fun with Numbers (20)(20 point(s))

    problem Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 t ...

  5. PAT Advanced 1023 Have Fun with Numbers (20) [⼤整数运算]

    题目 Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, ...

  6. PAT甲题题解-1023. Have Fun with Numbers (20)-大数加法

    和1024一样都是大数据的题,因为位数最多要20位,long long最多19位给一个num,求sum=num+num问sum包含的数字,是否是num的一个排列,即数字都一样,只是顺序不同罢了. #i ...

  7. 【PAT甲级】1023 Have Fun with Numbers (20 分)

    题意: 输入一个不超过20位的正整数,问乘2以后是否和之前的数组排列相同(数字种类和出现的个数不变),输出Yes或No,并输出乘2后的数字. AAAAAccepted code: #define HA ...

  8. PAT (Advanced Level) 1023. Have Fun with Numbers (20)

    手动模拟一下高精度加法. #include<iostream> #include<cstring> #include<cmath> #include<algo ...

  9. PAT 1023 Have Fun with Numbers[大数乘法][一般]

    1023 Have Fun with Numbers (20)(20 分) Notice that the number 123456789 is a 9-digit number consistin ...

随机推荐

  1. glup简单应用---gulpfile.js

    //npm install gulp -g (global环境) //npm install gulp --save-dev (项目环境) //在项目中install需要的gulp插件,一般只压缩的话 ...

  2. webpack-工程化工具

    一.简介 1.webpack 是 facebook 公司发布的一款工程化工具,早期有 react 使用. 2.核心理念: 一切都是资源,是资源我们就能模块化打包加载. 3.webpack 默认支持 c ...

  3. 集训队日常训练20181201 E 1005 : 小蝌蚪

    时间限制(普通/Java):500MS/1500MS     内存限制:65536KByte总提交: 25            测试通过:5 描述 有 n 个装着小蝌蚪的水缸排成一排,你拥有一个无限 ...

  4. 微信、qq二次分享

    前言 我们平时做微信分享的时候,一般分享出来的页面都是一个简单的html页面,不会加入框架之类的东西.所以当我们在分享出来的页面里面再次进行分享的时候,由于我们没有配置分享的标题.描述这些东西,分享出 ...

  5. jfinal afterJFinalStart中执行长久循环操作的解决方案:创建新线程

    很多时候,需要在jfinal中afterJFinalStart方法中,写一些需要一直循环运行的程序,做一些循环操作.但是在afterJFinalStart中,执行时间过长的话,会导致整个站点启动超时. ...

  6. [Linux] 文档编辑搜索

    vim filename press / type words which you want to search press Enter Q: How can I search only for wo ...

  7. [大数据面试题]storm核心知识点

    1.storm基本架构 storm的主从分别为Nimbus.Supervisor,工作进程为Worker. 2.计算模型 Storm的计算模型分为Spout和Bolt,Spout作为管口.Bolt作为 ...

  8. jmeter csv 参数化

    from:https://blog.csdn.net/bafasanqianzhang/article/details/77480297 [注意:csv可以上传txt,csv,另外参数必须正确否则会报 ...

  9. Java使用Redis--jedis

    参考:菜鸟教程 http://www.runoob.com/redis/redis-java.html 1.Java 使用 Redis 开始在 Java 中使用 Redis 前, 我们需要确保已经安装 ...

  10. 关于生物项目上的blast和viroblast

    最近要做一个跟生物有关的项目,隔行如隔山呀,好多工具以前都没听过,blast分到我头上啦,查查,查查 BLAST (Basic Local Alignment Search Tool)是一套在蛋白质数 ...