生词以及在文中意思

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. 承接Unity外包 U3D外包 Unity3D外包 小型Unity项目外包用Unity还是UE4

    转自mobilehub公众号(ID: mobilehub),作者:屠敏 VR浪潮席卷而来,相对于资本的狂热,现实中真正需要的是有实力的VR硬件研发团队和专业内容制作队伍.对于入门级的开发者而言,游戏引 ...

  2. git删除文件夹

    git  rm  要删除的文件夹  -r -f   git  commit  -m  'del  config' git  push 使用场景,删除test文件夹,本来在码云上,正常的文件夹右击会出现 ...

  3. obfuscate 混淆 verb

  4. Linux删除/boot后该如何恢复

    一.其实不光boot目录被删除,也有系统启动不起来等,一直因为/boot这个目录的的问题,今天就来解决一下 Centos 6 1.进入救援,先修复vmlinz(内核) chroot /mnt/sysi ...

  5. php国家或者编码英文字母排序

    1.直接复制传入需要排序的字符,然后可以把返回的数据当key,传送给前台function getFirstCharter($str){ if(empty($str)){return '';} $fch ...

  6. ASP.NET Razor - 标记

    目录 什么是 Razor? Razor 帮助器 ASP.NET Razor - C# 和 VB 代码语法 主要的 Razor C# 语法规则 它是如何工作的? 使用对象 If 和 Else条件 读取用 ...

  7. [luogu P3953] [noip2017 d1t3] 逛公园

    [luogu P3953] [noip2017 d1t3] 逛公园 题目描述 策策同学特别喜欢逛公园.公园可以看成一张$N$个点$M$条边构成的有向图,且没有 自环和重边.其中1号点是公园的入口,$N ...

  8. react - next.js 引用本地图片和css文件

    1. 图片 把图片放在/static/文件夹中,在component中用img tag: <img src={'../static/icon.png'} /> 2. css 把css文件放 ...

  9. samba及其基本应用

    Samba 137/udp,138/udp,139/tcp,445/tcp windowns主机共享: linux主机进行访问查看资源:smbclient -L Server_IP -U 用户名 li ...

  10. hdu6415 记忆化搜索或找规律

    Rikka with Nash Equilibrium Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Sub ...