如用到bign类参见大整数加减乘除模板

424 - Integer Inquiry

#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#define N 10050
using namespace std;
string s;
int ans[N];
int main()
{
int i, j;
while (cin>>s, s[] != '')
{
for (i = s.length() - , j = ; i >= ; i--, j++)
ans[j] += (s[i] - '');
}
for (i = ; i < N - ; i++)
{
ans[i + ] += ans[i] / ;
ans[i] %= ;
}
i = N - ;
while (!ans[i] && i > )
i--;
while (i >= )
cout<<ans[i--];
cout<<endl;
return ;
}

10106 - Product

#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#define N 550
using namespace std;
int ans[N];
string s1, s2; int main()
{
int i, j, ls1, ls2, len;//tmp表示进位
while (cin>>s1>>s2)
{
ls1 = s1.length() - ;
ls2 = s2.length() - ;
len = ls1 + ls2;
memset(ans, , sizeof(ans));
for (i = ls1; i >= ; i--)
for (j = ls2; j >= ; j--)
{
ans[len - (i + j)] += (s1[i] - '') * (s2[j] - '');
}
len++;
for (i = ; i < len; i++)
{
ans[i + ] += ans[i] / ;
ans[i] = ans[i] % ;
}
while (!ans[len] && len > )//去除前导0
len--;
for (; len >= ; len--)
cout<<ans[len];
cout<<endl;
}
return ;
}

465 - Overflow

int main()
{
//ifstream cin("test.in");
bign a, b, c;
char ch;
bign d = INT_MAX;
string sa, sb;
while (cin>>sa>>ch>>sb)
{ cout<<sa<<' '<<ch<<' '<<sb<<endl;
a = sa;
b = sb;
if (d < a)
cout<<"first number too big"<<endl;
if (d < b)
cout<<"second number too big"<<endl;
if (ch == '+')
c = a + b;
else
c = a * b;
cout<<c<<endl;
if (d < c)
cout<<"result too big"<<endl;
}
return ;
}

748 - Exponentiation

int main()
{
string sa, sb;
bign a, b;
int p, n, i;
while (cin>>sa>>n)
{
p = ;
while (sa[p] != '.')
p++;
sa.erase(sa.begin() + p);
a = sa;
b = a ^ n;
sb = b.to_str();
p = ( - p) * n;
for (i = b.length(); i < p; i++)
sb += '';
sb.insert(sb.begin() + p, '.');
p = ;
while (sb[p] == '')
p++;
for (i = sb.length() - ; i >= p; i--)
cout<<sb[i];
cout<<endl;
}
return ;
}

10494 - If We Were a Child Again

int main()
{
//string sa, sb;
bign a, b, c;
char ch;
while (cin>>a>>ch>>b)
{
if (ch == '/')
c = a / b;
else
c = a % b;
cout<<c<<endl;
}
return ;
}

最新文章

  1. SAP 使用较频繁的日期时间处理函数总结
  2. Android studio git 本地仓库和远程仓库节点对比
  3. The main difference between Java &amp; C++(转载)
  4. 低功耗蓝牙4.0BLE编程-nrf51822开发(9)
  5. WPF学习02:Routed Events
  6. ASP.Net用jQuery ajax实现页面局部刷新
  7. hdu3714 三分
  8. JavaScript高级程序设计(读书笔记)(一)
  9. ionic cordova platform add android Cordova failed to install plugin Error: ENOENT: no such file or directory AndroidManifest.xml
  10. 小P的字符串
  11. java常用技术名词解析
  12. 【原创】利用Office宏实现powershell payload远控
  13. jboss 异常处理
  14. 深入浅出 JMS(三) - ActiveMQ 消息传输
  15. 关于ARM的B,BL跳转指令
  16. 每日英语:Genetic Manipulation Extends Life of Mice 20%
  17. ExtJS错误解决 Cannot read property &#39;on&#39; of undefined
  18. css 盒子垂直居中
  19. 从U盘安装linux(前人踩坑后人乘凉)
  20. 解决:fontawesome-webfont.woff2?v=4.6.3 404 (Not Found)

热门文章

  1. Springboot整合elasticsearch以及接口开发
  2. python爬取网页图片(二)
  3. 51nod1127 最短的包含字符串 尺取法
  4. Java标识符的习惯命名规范
  5. vue学习之遇见的问题
  6. scala打印error,debug,info
  7. jmeter 连接 sqlite 进行压力测试
  8. iOS定位--CoreLocation框架
  9. MySQL——sql注入
  10. ubuntu下pycharm无法使用pip安装python包的修复方案