手动模拟一下高精度加法。

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<map>
#include<queue>
#include<vector>
using namespace std; char s[],t[],c[];
int lens,lenc; void f(char *x)
{
int len=strlen(x);
for(int i=;i<len/;i++) swap(x[i],x[len-i-]);
} void add()
{
int k=;
int len=strlen(s);
int num1,num2; for(int i=;i<=len;i++)
{
if(s[i]==) num1=num2=;
else num1=num2=s[i]-'';
c[i]=(num1+num2+k)%+'';
k=(num1+num2+k)/;
}
if(c[len]=='') c[len]=;
f(c);
// printf("%s\n",c);
} bool check()
{
char tmps[],tmpc[];
if(lens!=lenc) return ;
strcpy(tmps,s); strcpy(tmpc,c);
sort(tmps,tmps+lens); sort(tmpc,tmpc+lenc);
for(int i=;s[i];i++) if(tmps[i]!=tmpc[i]) return ;
return ;
} int main()
{
memset(s,,sizeof s);memset(t,,sizeof t);memset(c,,sizeof c);
scanf("%s",s); strcpy(t,s);
f(s); f(t); add(); f(s);
lens=strlen(s);lenc=strlen(c);
if(check()) printf("Yes\n");
else printf("No\n");
printf("%s\n",c);
return ;
}

最新文章

  1. GridView导出Excel(中文乱码)
  2. vue 2 滚动条加载更多数据实现
  3. subline 快捷键
  4. QRCode.jar生成二维码
  5. php循环创建目录
  6. theos的makefile写法
  7. ListView属性
  8. 利用Paramiko模块远程连接Linux
  9. 老李分享:loadrunner用javavuser进行接口测试
  10. 2017 多校训练 1002 Balala Power!
  11. DataBase MongoDB集群方案介绍
  12. MoonLight可视化订单需求区域分析系统前端
  13. Java虚拟机垃圾收集算法
  14. Python笔记-面向对象编程
  15. vue使用技巧(分页、nextTick、复制对象)
  16. Python 验证线程是数据共享的
  17. mysql 开发进阶篇系列 27 数据库字符集设置
  18. 洛谷 P2257 YY的GCD
  19. Spring ApplicationContext(六)BeanPostProcessor
  20. 宿主在Windows Service中的WCF(创建,安装,调用) (host到exe,非IIS)

热门文章

  1. Apache的最小配置
  2. 使用onclick跳转到其他页面。使用button跳转到指定url
  3. linux 进程监控和自动重启的简单实现(转)
  4. perl的USE和require
  5. MyEclipse build path no actions available
  6. MyBatis 返回新增数据的自增id
  7. php composer 安装
  8. springmvc+mybatis下载项目自带模板
  9. js操作select和option
  10. Video Cards