题意:

给定一个正整数(最多有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. ElasticSearch数据副本模型

    介绍 ES里面的每一个索引(Index)由多个shard组成,每一个shard有多个副本.这些副本被称为同步组.当增加或者删除文档时,这些副本之间必须保持同步,以便让所有副本都能包含相同的文档.如果同 ...

  2. LeetCode第[15]题(Java):3Sum (三数之和为目标值)——Medium

    题目难度:Medium 题目: Given an array S of n integers, are there elements a, b, c in S such that a + b + c  ...

  3. ie if判断

    <p> </p> <!--[if lt IE 7]> <html lang="en" ng-app="myApp" c ...

  4. HttpClient for .NET 4.0

    Install-Package Microsoft.Net.Http -Version 2.2.29

  5. python----标准库概要

    操作系统接口 os模块提供了不少与操作系统相关联的函数. >>> import os >>> os.getcwd() # 返回当前的工作目录 'C:\\Python ...

  6. python扫描proxy并获取可用代理ip列表

    mac或linux下可以work的代码如下: # coding=utf-8 import requests import re from bs4 import BeautifulSoup as bs ...

  7. 003——VUE操作元素属性

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. NPOI将xls文件解析为DataTable类数据

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

  9. OC-如何隐藏NSLog打印的自带信息

    #ifdef DEBUG #define NSLog(FORMAT, ...) fprintf(stderr,"%s\n",[[NSString stringWithFormat: ...

  10. Android 进阶7:进程通信之 AIDL 的使用

    读完本文你将了解: AIDL 是什么 AIDL 支持的数据类型 AIDL 如何编写 AIDL 实例 创建 AIDL 编写服务端代码 编写客户端代码 运行结果 总结 代码地址 Thanks 记得 201 ...