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 ...
随机推荐
- 亚马逊EC2
亚马逊EC2编辑 本词条缺少信息栏,补充相关内容使词条更完整,还能快速升级,赶紧来编辑吧! 亚马逊弹性计算云(EC2,Elastic Compute Cloud)是一个让使用者可以租用云端电脑运行所需 ...
- angular之 $watch 和$digest 和$apply和$observe的区别
$watch 代表的就是对数据源的监听,当数据源发生变化,就会触发第二个参数的回调函数 $digest 代表触发一个数据源变化的事件 $apply 代表对于$digest的一个封装,他多了一个参数 . ...
- 【辅助工具】Python实现微信跳一跳
最近迷上了微信跳一跳小游戏,正好也看到知乎上有大神分享了技术贴,我也参考了好多资料,原理就是通过abd命令截取图片,python计算两个点距离,然后转化按压时间,让电脑来完成游戏.我花了很长时间才把程 ...
- Makefile的补充学习2
Makefile中使用通配符(1)* 若干个任意字符(2)? 1个任意字符(3)[] 将[]中的字符依次去和外面的结合匹配 还有个%,也是通配符,表示任意多个字符,和*很相似,但是%一般只用于规则描述 ...
- linux命令三
作业一:1) 将用户信息数据库文件和组信息数据库文件纵向合并为一个文件/1.txt(覆盖) [root@bogon test]# cat /etc/passwd /etc/group > /1. ...
- Linux下用c语言实现whereis.
简单的一个whereis的实现,代码如下: #include <stdio.h> #include <errno.h> #include <dirent.h> #i ...
- LeetCode OJ:Simplify Path(简化路径)
Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", ...
- 条款11:记得在operator=中处理自赋值的情况。
本来的版本是这样的: Widget & Widget::operator=(Widget rhs) { delete pb;//这里可能直接将rhs的pb删除了 pb = new (*rhs. ...
- dubbo-monitor安装、 监控中心 配置过程
简单介绍下monitor: Simple Monitor挂掉不会影响到Consumer和Provider之间的调用,所以用于生产环境不会有风险. 配置好了之后可以结合admin管理后台使用,可以清晰的 ...
- ES中保护对象的措施总结
必要性: JS中的对象可随意修改属性值,可随意添加删除属性,太乱,数据安全得不到保障. 如何保护: 保护属性: 保护对属性值的修改 对象属性分为: 命名属性: 可直接用.访问到的属性 数据属性: 直 ...