题意:

给定一个正整数(最多有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. Educational Codeforces Round 22E

    给你n和k,n个数,每个数范围1e5,m次查询,每次查询区间(l,r),在区间中的每个数,如果超过k次只算k次,否则算原来的次数,求总次数,强制在线 解法:线段树维护区间中每个数经过k次到达的点pos ...

  2. 33-THREE.JS 圆柱体

    <!DOCTYPE html> <html> <head> <title></title> <script src="htt ...

  3. Linux下的目录结构

    1./ -根 每个文件和目录从根目录开始 只有root用户具有该目录下的写权限,请注意,/root是root用户的主目录,这与/.不一样. 2. /bin  -用户二进制文件 包含二进制可执行的文件 ...

  4. android textview xml 属性设置

     android:ems 设置TextView的宽度为N个字符的宽度. android:maxems 设置TextView的宽度为最长为N个字符的宽度.与ems同时使用时覆盖ems选项. andr ...

  5. 说说geotools中坐标转换那点事

    概述: 本文说说geotools中坐标转换的那点事情,以WGS84和web墨卡托相互转换为例. 效果: 转换前 转换后 单个Geometry转换 实现代码: package com.lzugis.ge ...

  6. CSS3实现多列纵向滚动

    效果如图: 小程序wxml: <view class='wraper'> <view class="header"> 头部 </view> &l ...

  7. linux中文件或者文件夹的基本操作(复制,移动,删除,查找,压缩)

    linux 文件(文件夹)的创建,复制,移动,重命名,删除基本命令 复制文件或整个目录 cp 源文件名 目标文件夹/[目标文件名]cp -rv 源文件夹 目标文件夹/[目标文件夹名] --r 递归目录 ...

  8. Cloudera Manager (centos)安装详细介绍

    文章全部来自:Cloudera Manager (centos)安装详细介绍http://www.aboutyun.com/thread-9190-1-1.html(出处: about云开发) 这里已 ...

  9. IOS Quartz 2D 学习(1)

    IOS提供两种创建图形的途径: 1.OpenGL. 2.Quartz.Core Animation.UIKit图形支持. UIKit的图形系统 1.视图绘画周期: DrawRect方法,在任何时候,当 ...

  10. WCF *.svc 自定义地址路由映射

    一般在创建WCF服务时会用Serivce.svc文件访问,地址如:http://localhost/applicationname/Serivce.svc/Name 现在用路由映射成:http://l ...