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 ...
随机推荐
- dpdk对虚拟化的支持调研
目录: 虚拟化 dpdk的实现研究 virtio vhost SR-IOV 热迁移相关 研究拓展 本文记录近期对dpdk在虚拟化和云计算领域应用的研究成果,内容梳理如下. 虚拟化 虚拟化,抽象来说,就 ...
- 将hibernate.cfg.xml文件都放到spring中时报错
报错如下所示: 私以为是配置文件出现问题了. <?xml version="1.0" encoding="UTF-8"?> <beans xm ...
- C++(十八) — 内存模式、堆和栈
1.内存模式 一个程序执行时,先复制到内存,然后CPU逐句读取指令执行. 每个存储单元存放一个字节(8bit)数据,每个有一个唯一的地址,地址是顺序编码的.比如:一台计算机256MB内存,则有256* ...
- 【sparkStreaming】kafka作为数据源的生产和消费
1.建立生产者发送数据 (1)配置zookeeper属性信息props (2)通过 new KafkaProducer[KeyType,ValueType](props) 建立producer (3) ...
- 【51nod-1605】棋盘问题
上帝创造了一个n*m棋盘,每一个格子都只有可能是黑色或者白色的. 亚当和夏娃在玩一个游戏,每次寻找边长为x的正方形,其中每个格子必须为黑色,然后将这些格子染白. 如果谁不能操作了,那么那个人就输了. ...
- 反汇编工具 objdump的使用简介
arm-linux-objdump -D led.elf > led_elf.dis objdump是gcc工具链中的反汇编工具,作用是由编译链接好的elf格式的可执行程序反过来得到反汇编代码 ...
- LeetCode OJ:Permutations(排列)
Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the follow ...
- TCPL学习毕节:第六章hash表
对于P126的哈希表构成: struct nlist *install(char *name, char *defn) { struct nlist *np; unsigned hashval; if ...
- CSS:Tutorial three
1.CSS Links links can be styled differently depending on what state they are in. The four links stat ...
- 20165210 Java第四次实验报告
20165210 实验四 Android程序设计 实验步骤 第24章:初识Android 任务一:完成Hello World, 要求修改res目录中的内容,Hello World后要显示自己的学号 学 ...