permutation: 排列(方式);组合(方式) 通用方法 循环遍历计算结果,拼成字符串 map封装大数字符次数结果,循环比较倍数结果与原数字符个数及种类 不手生的情况下,10分钟内a题 测试用例 input: 1234567899 output: Yes 2469135798 1. 2. 3. 4. 5. ac代码 时间长手生,撸代码时间耗费偏多 #include #include<iostre...
1023 Have Fun with Numbers(20 分) Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number consisting exactly the numbers from 1 to 9, only in a...
#include<iostream>#include<cstdio>#include<string>#include<string.h>#include<algorithm>usingnamespacestd;intmain(){#if ONLINE_JUDGE#elsefreopen("input.txt","r",stdin);#endifcharinput[21];scanf("%s",input);strings=input;intnum[10]={0};// 0->9boolisFun=true;for(inti=0;i<s.size()...
和1024一样都是大数据的题,因为位数最多要20位,long long最多19位 给一个num,求sum=num+num 问sum包含的数字,是否是num的一个排列,即数字都一样,只是顺序不同罢了。 View Code
PAT_甲级_1023 Have Fun with Numbers 题目大意: 给出一个长度不超过20的整数,问这个整数乘以2以后的数位是否为原数数位的一个排列 算法思路: 由于长度有可能达到20位,超过了long long的存储范围,所以这里采用string存储输入的整数。该题只需要解决两个问题,第一个就是如何判断2个整数的互为排列,第二个就是...
PAT 1023. Have Fun with Numbers (20) 模拟大数乘法,#include#include#include#include#include#include#include#include#includeusingnamespacestd;#defineM30intinum[M];intans[M];//90-48=42min//耗时于各种错误,变量搞错,参数搞混,以及num>=10写成num>10//题意:
learn && wrong: 1、 标准答案不是我的散列, (1)是先比较两个数长度是否相同, (2)相同则,先让a.d[i]在count散列数组++,另外一个--, (3)最后遍历一次count, 如果数字不止20,那就这个复杂度好点,如果只有20,那就差不多 我遍历了两次,它是遍历一次+遍历count(count只有9个下标 ...
题目PAT A 1023 链接 题目大意 给一个最多20位的由1-99个数字组成的整数,问把该数字乘2以后,所得整数是不是原来数字的一个排列。 解题思路 大整数加法,统计每个数字出现的次数,对比一下即可 #include<bits/stdc++.h>usingnamespacestd;stringAdd(stringa,stringb){intc=0;inti=a.size()-1,j=b.size()...
Now you are suppose to check if there are more numbers with this property. That is, double a given number with digits, you are to tell if the resulting number consists of only a permutation of the digits in the original number.
1023 Have Fun with Numbers (20 分) Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number consisting exactly the numbers from 1 to 9, only in ...