题意:

给定一个正整数(最多有20位),假设这个数是a1a2a3...ak,把这个数乘以2倍,看得到的结果是否仍然是a1a2a3...ak的一个排列 
 
思路:

大整数与int型整数的乘法;简单哈希。

代码:

#include <cstdio>
#include <cstring>

struct bign{
    ];
    int len;
    bign(){
        memset(digit,,sizeof(digit));
        len=;
    }
};

bign change(char str[])
{
    bign c;
    c.len=strlen(str);
    int n=c.len;
    ;i<n;i++){
        c.digit[i]=str[n--i]-';
    }
    return c;
}

bign multiply(bign a,int b)
{
    bign c;
    ;
    ;i<a.len;i++){
        int temp=a.digit[i]*b+carry;
        c.digit[c.len++]=temp%;
        carry=temp/;
    }
    ){
        c.digit[c.len++]=carry%;
        carry/=;
    }
    return c;
}

void print(bign a)
{
    ;i>=;i--)
        printf("%d",a.digit[i]);
}

int main()
{
    ];
    scanf("%s",str);
    ];
    memset(hashtable,,sizeof(hashtable));
    int len=strlen(str);
    ;i<len;i++)
        hashtable[str[i]-']++;
    bign a=change(str);
    bign double_a=multiply(a,);
    ;i<double_a.len;i++)
        hashtable[double_a.digit[i]]--;
    bool flag=true;
    ;i<;i++){
        ) {
            flag=false;
            break;
        }
    }
    if(flag==true) printf("Yes\n");
    else printf("No\n");

    print(double_a);
    ;
}

1023 Have Fun with Numbers的更多相关文章

  1. PAT 1023 Have Fun with Numbers

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

  2. PAT 甲级 1023 Have Fun with Numbers(20)(思路分析)

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

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

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

  4. pat 1023 Have Fun with Numbers(20 分)

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

  5. 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 ...

  6. 1023 Have Fun with Numbers (20 分)

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

  7. 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 ...

  8. 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 ...

  9. PTA (Advanced Level) 1023 Have Fun with Numbers

    Have Fun with Numbers Notice that the number 123456789 is a 9-digit number consisting exactly the nu ...

  10. PAT 甲级 1023 Have Fun with Numbers

    https://pintia.cn/problem-sets/994805342720868352/problems/994805478658260992 Notice that the number ...

随机推荐

  1. java socket - 传递对象

    Person类: package com.zhyea.olproxy.socket; import java.io.Serializable; public class Person implemen ...

  2. 《JavaScript高级程序设计》第6章补充 继承

    基于原型链继承 将父类的实例赋给子类的prototype来实现继承. 原理:父类的实例有父类所有的实例属性和原型方法,将它赋给子类的prototype后,子类的创建的实例就有会__proto__属性指 ...

  3. linux安装----gcc

    Linux中gcc是个编译工具,可以将源码文件(c c++ java文件) 编译成 二进制文件.

  4. docker安装脚本

    此docker安装脚本为官方提供的,可以从网上下载,此处直接把脚本内容贴上. #!/bin/sh set -e # This script is meant for quick & easy ...

  5. 值提供器 AND 模型绑定器

    本章介绍了值提供器的作用,ASP MVC自带的5中值提供器.以及模型绑定器的作用,自定义模型绑定器并使用自定义的模型绑定器(类型上加上[ModelBinder(typeof(xx))]或者在全局模型绑 ...

  6. 【sparkStreaming】SparkStream的创建

    DStream编程数据模型 DStream(Discretized Stream)作为Spark Streaming的基础抽象,它代表持续性的数据流. 这些数据流既可以通过外部输入源赖获取,也可以通过 ...

  7. hdu4715

    题解: 二分图判断 建立原图的补图 判断是否是二分图 代码: #include<cstdio> #include<cmath> #include<cstring> ...

  8. MySQL index merge

    深入理解 index merge 是使用索引进行优化的重要基础之一. [ index merge]       当where谓词中存在多个条件(或者join)涉及到多个字段,它们之间进行 AND 或者 ...

  9. OC-存档

    Δ一.   .plist文件 .plist文件是一个属性字典数组的一个文件: .plist文件可以用来存储:字典.数组.字符串等对象数据,可以混搭存储 [注]iOS开发中,plist文件一般用于app ...

  10. OC-Foundation框架

    ========================== Foundation框架下的常用类 ========================== 一.[NSNumber]================ ...