pat_1023
来源:互联网 发布:pollution 的数据 编辑:程序博客网 时间:2024/06/16 10:46
输入使用字符串,直接使用哈希数组
#include <iostream>#include <string.h>#include <memory.h>using namespace std;char num[25];char num2[25];int hash1[10];int main(){ int i,j;scanf("%s",num);memset(hash1,0,sizeof(hash1));int n=strlen(num);int temp=0;j=0;for(i=n-1;i>=0;i--){ int t=num[i]-'0';hash1[t]++;t=t*2+temp; temp=t/10;t=t%10;num2[j]=t+'0';j++; hash1[t]--;} if(temp>0) { num2[j]=temp+'0'; j++; } for(i=0;i<10;i++) if(hash1[i]!=0) { cout<<"No";break;} if(i==10)cout<<"Yes"; cout<<endl; for(i=j-1;i>=0;i--)cout<<num2[i]; cout<<endl; return 0;}
- pat_1023
- PAT_1023: Have Fun with Numbers
- PAT_1023. Have Fun with Numbers
- PAT_1023 组个最小数
- ubuntu开启SSH服务
- Power BI for Office 365(五)Power View第二部分
- 最小生成树之prim算法
- Java关键字final和static总结
- javascript深入理解js闭包
- pat_1023
- Kubuntu 10.10 速配指南
- 基于SQL Server的数据处理技术及应用
- 小白用超级终端
- C++产生随机数(整理)
- 看图理解单链表的反转
- 采用FLAG_ACTIVITY_CLEAR_TOP退出整个程序(多activity)
- spring如何引用properties文件里的配置
- Uva - 10397 - Connect the Campus