1023 Have Fun with Numbers
题意:
大整数与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的更多相关文章
- PAT 1023 Have Fun with Numbers
1023 Have Fun with Numbers (20 分) Notice that the number 123456789 is a 9-digit number consisting ...
- 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 ...
- PAT 1023 Have Fun with Numbers[大数乘法][一般]
1023 Have Fun with Numbers (20)(20 分) Notice that the number 123456789 is a 9-digit number consistin ...
- 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 ...
- 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 ...
- 1023 Have Fun with Numbers (20 分)
1023 Have Fun with Numbers (20 分) Notice that the number 123456789 is a 9-digit number consisting ...
- 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 ...
- 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 ...
- 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 ...
- PAT 甲级 1023 Have Fun with Numbers
https://pintia.cn/problem-sets/994805342720868352/problems/994805478658260992 Notice that the number ...
随机推荐
- java socket - 传递对象
Person类: package com.zhyea.olproxy.socket; import java.io.Serializable; public class Person implemen ...
- 《JavaScript高级程序设计》第6章补充 继承
基于原型链继承 将父类的实例赋给子类的prototype来实现继承. 原理:父类的实例有父类所有的实例属性和原型方法,将它赋给子类的prototype后,子类的创建的实例就有会__proto__属性指 ...
- linux安装----gcc
Linux中gcc是个编译工具,可以将源码文件(c c++ java文件) 编译成 二进制文件.
- docker安装脚本
此docker安装脚本为官方提供的,可以从网上下载,此处直接把脚本内容贴上. #!/bin/sh set -e # This script is meant for quick & easy ...
- 值提供器 AND 模型绑定器
本章介绍了值提供器的作用,ASP MVC自带的5中值提供器.以及模型绑定器的作用,自定义模型绑定器并使用自定义的模型绑定器(类型上加上[ModelBinder(typeof(xx))]或者在全局模型绑 ...
- 【sparkStreaming】SparkStream的创建
DStream编程数据模型 DStream(Discretized Stream)作为Spark Streaming的基础抽象,它代表持续性的数据流. 这些数据流既可以通过外部输入源赖获取,也可以通过 ...
- hdu4715
题解: 二分图判断 建立原图的补图 判断是否是二分图 代码: #include<cstdio> #include<cmath> #include<cstring> ...
- MySQL index merge
深入理解 index merge 是使用索引进行优化的重要基础之一. [ index merge] 当where谓词中存在多个条件(或者join)涉及到多个字段,它们之间进行 AND 或者 ...
- OC-存档
Δ一. .plist文件 .plist文件是一个属性字典数组的一个文件: .plist文件可以用来存储:字典.数组.字符串等对象数据,可以混搭存储 [注]iOS开发中,plist文件一般用于app ...
- OC-Foundation框架
========================== Foundation框架下的常用类 ========================== 一.[NSNumber]================ ...