1023. Have Fun with Numbers (20) PAT甲级
来源:互联网 发布:java缓冲流的作用 编辑:程序博客网 时间:2024/04/28 01:05
传送门
#include<stdio.h>#include<string.h>struct bign{ int d[21]; int len; bign(){ memset(d,0,sizeof(d)); len=0; }};bign change(char str[]){ bign a; a.len=strlen(str); for(int i=0;i<a.len;i++){ a.d[i]=str[a.len-i-1]-'0'; } return a;}bign mul(bign a,int b){ bign c; int carry=0; for(int i=0;i<a.len;i++){ int temp=a.d[i]*b+carry; c.d[c.len++]=temp%10; carry=temp/10; } while(carry!=0){ c.d[c.len++]=carry%10; carry/=10; } return c;}bool Judge(bign a,bign b){ if(a.len!=b.len) return false; int count[10]={0}; for(int i=0;i<a.len;i++){ count[a.d[i]]++; } for(int i=0;i<a.len;i++){ count[b.d[i]]--; } for(int i=0;i<10;i++){ if(count[i]!=0) return false; } return true;} void print(bign a){ for(int i=a.len-1;i>=0;i--){ printf("%d",a.d[i]); }}int main(){ char str[21]; scanf("%s",str); bign a=change(str); bign b=mul(a,2); if(Judge(a,b)) printf("Yes\n"); else printf("No\n"); print(b);}
0 0
- PAT 甲级 1023. Have Fun with Numbers
- 【PAT甲级】1023. Have Fun with Numbers (20)
- 1023. Have Fun with Numbers (20) PAT甲级
- PAT甲级练习1023. Have Fun with Numbers (20)
- PAT甲级1023. Have Fun with Numbers (20)
- PAT甲级 1023. Have Fun with Numbers (20)
- PAT 甲级 1023. Have Fun with Numbers (20)
- PAT甲级 1023. Have Fun with Numbers (20)
- PAT 甲级 1023 Have Fun with Numbers
- PAT甲级练习题A1023. Have Fun with Numbers (20)
- 【PAT】1023. Have Fun with Numbers (20)
- PAT: 1023. Have Fun with Numbers (20)
- PAT 1023. Have Fun with Numbers (20)
- PAT 1023. Have Fun with Numbers (20)
- PAT 1023. Have Fun with Numbers (20)
- PAT 1023. Have Fun with Numbers (20)
- pat 1023. Have Fun with Numbers (20)
- PAT 1023. Have Fun with Numbers (20)
- document.compatMode属性
- 矩阵分解在协同过滤推荐算法中的应用
- PGA Tour Prize Money(UVa207)
- LeetCode 495. Teemo Attacking 题目翻译+AC代码
- 欢迎使用CSDN-markdown编辑器
- 1023. Have Fun with Numbers (20) PAT甲级
- 对象包装器与自动装箱
- 最长上升子序列(百练2757)
- 谷哥的小弟学后台(06)——JDBC
- leetcode - 35.Search Insert Position
- 泛型数组列表
- 在C语言中用ASSERT调试的八个技巧
- 第002弹:Java 中的值传递和引用传递
- nyoj7_街区最短路径问题