生词以及在文中意思

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. 对java中路径的一些理解

    开始前先贴一下项目结构 public class TestLocation { @Test public void test1(){ String s1 = Objects.requireNonNul ...

  2. Tomcat性能优化(转载)

    出处:微信订阅号GitChat精品课程 — Tomcat性能优化 Tomcat 简单介绍 Sun 公司创建了第一个 Servlet 容器,即 Java Web Server,但 JWS 只是为了演示 ...

  3. Java——ping & telnet实现

    ping & telnet 实现类: import org.springframework.data.web.JsonPath; import java.io.IOException; imp ...

  4. Hibernate实例——Customer表的展示

    Hibernate.cfg.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibe ...

  5. sublime text3使用

    设置tab键为若干空格 { "tab_size": 4, "translate_tabs_to_spaces": true }

  6. 详解MySQL中concat函数的用法(连接字符串)

    MySQL中concat函数 使用方法: CONCAT(str1,str2,…) 返回结果为连接参数产生的字符串.如有任何一个参数为NULL ,则返回值为 NULL. 注意: 如果所有参数均为非二进制 ...

  7. 线性代数导论 | Linear Algebra 课程

    搞统计的线性代数和概率论必须精通,最好要能锻炼出直觉,再学机器学习才会事半功倍. 线性代数只推荐Prof. Gilbert Strang的MIT课程,有视频,有教材,有习题,有考试,一套学下来基本就入 ...

  8. .NET Core WEB API中接口参数的模型绑定的理解

    在.NET Core WEB API中参数的模型绑定方式有以下表格中的几种: 微软官方文档说明地址:https://docs.microsoft.com/zh-cn/aspnet/core/web-a ...

  9. windows下载mysql5.7压缩包配置安装mysql

    windows安装mysql5.7有两种方式 1.下载.msi安装文件直接根据界面提示进行安装 2.下载.biz或.zip压缩包 注:本次在win10系统下使用压缩包进行安装mysql5.7 mysq ...

  10. hadoop hdfs 数据迁移到其他集群

    # hadoop fs -cat /srclist Warning: $HADOOP_HOME is deprecated. hdfs://sht-sgmhadoopcm-01:9011/jdk-6u ...