题意:

给定一个正整数(最多有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. vmware增加共享文件夹

    增加共享文件夹 VMWare提供共享文件夹功能.前提是在虚拟机中安装VMware tools 1. 安装VMware tools 会自动在虚拟机中的/media/VMware Tools/中有个压缩包 ...

  2. python twisted教程[资料]

    python twisted教程 一,异步编程 http://www.douban.com/note/232200511/   python twisted教程 二:缓慢的诗 http://www.d ...

  3. Netty(RPC高性能之道)原理剖析

    1,Netty简述 Netty 是一个基于 JAVA NIO 类库的异步通信框架,用于创建异步非阻塞.基于事件驱动.高性能.高可靠性和高可定制性的网络客户端和服务器端 RPC高性能分析,请参考文章“[ ...

  4. tracecaller.cs

    #region Utility #if TRACE private const string Traceformat = "\"{0}\",\"{1:yyyy- ...

  5. 51nod-1526-贪心+Trie

    题目链接在这 题目来源: CodeForces 基准时间限制:1 秒 空间限制:131072 KB 分值: 320 难度:7级算法题 收藏 关注 班里有n个同学.老师为他们选了n个笔名.现在要把这些笔 ...

  6. css中实现显示和隐藏(转)

    CSS中的display和visibility      在平时的开发过程中,总是会遇到一些文字在特定的场景下显示或者隐藏来达到我们想要的效果,css中display和visibility语法,他们都 ...

  7. Myeclipse快捷键的设置以及默认的编码格式

    设置默认的编码格式

  8. python基础之网络基础

    一.操作系统基础 操作系统:(Operating System,简称OS)是管理和控制计算机硬件与软件资源的计算机程序,是直接运行在“裸机”上的最基本的系统软件,任何其他软件都必须在操作系统的支持下才 ...

  9. php判断字符串长度 strlen()与mb_strlen()函数

    PHP strlen() 函数 定义和用法 strlen() 函数返回字符串的长度. 语法 strlen(string) 参数:string <?php $str=‘中文a字1符‘; echo ...

  10. mcake活动维护常见问题记录【wap端】 ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★

    ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ wap端问题及解决方法 ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ 一.wap端弹窗 .Dialogbg-Select{ background-co ...