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 ...
随机推荐
- cvFindContours函数
cvFindContours函数: int cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** first_contour, in ...
- C#外部类、内部类(嵌套类)之间的成员访问特点
最近程序中需要用到多线程工作下的单例模式.而其多种实现方法中,利用内部类实现懒汉模式是一种值得推荐的方式.顺便也就对内部类和外部类之间的关系做了一下研究,总结如下(理解不困难,不粘贴代码了,有需要的留 ...
- Apache Samza流处理框架介绍——kafka+LevelDB的Key/Value数据库来存储历史消息+?
转自:http://www.infoq.com/cn/news/2015/02/apache-samza-top-project Apache Samza是一个开源.分布式的流处理框架,它使用开源分布 ...
- 【lightoj-1094】树的直径(DFS)
链接:http://www.lightoj.com/volume_showproblem.php?problem=1094 题意: 一共n各节点编号0-n-1, 输入n-1条无向边代表u-v距离为w, ...
- LeetCode OJ:Remove Duplicates from Sorted Array(排好序的vector去重)
Given a sorted array, remove the duplicates in place such that each element appear only once and ret ...
- iis不能访问html
在iis中配置好虚拟目录后,打开目录下的一个html文件,发现不是按照预想的输出,查看源代码后发现代码是: <html><head></head><body& ...
- 函数声明提升机制在浏览器中的bug
JavaScript 解释器中存在一种变量声明被提升(hoisting)的机制,也就是说变量(函数)的声明会被提升到作用域的最前面,即使写代码的时候是写在最后面,也还是会被提升至最前面. 但通过测试, ...
- access_ok | 检查用户空间内存块是否可用
access_ok() 函数是用来代替老版本的 verify_area() 函数的.它的作用也是检查用户空间指针是否可用. 函数原型:access_ok (type, addr, size); 变量说 ...
- Android系统自带分享功能的实现(可同时分享文字和图片)
/** * 分享功能 * * @param context * 上下文 * @param activityTitle * Activity的名字 * @param msgTitle * 消息标题 ...
- 8.var目录下的文件和目录详解
1./var目录下的文件和目录详解. /var (该目录存放的是不断扩充且经常修改的目录,包括各种日志文件或者pid文件,存放linux的启动日志和正在运行的程序目录(变化的目录:一般是日志文件,ca ...