如用到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 ;
}

Volume 1. Big Number(uva)的更多相关文章

  1. Volume 1. Sorting/Searching(uva)

    340 - Master-Mind Hints /*读了老半天才把题读懂,读懂了题输出格式没注意,结果re了两次. 题意:先给一串数字S,然后每次给出对应相同数目的的一串数字Si,然后优先统计Si和S ...

  2. UVA - 10591 Happy Number

    Happy Number UVA - 10591 Let the sum of the square of the digits of a positive integer S0 be represe ...

  3. Extending a logical volume in a virtual machine running Red Hat or Cent OS (1006371)

    Purpose This article provides steps for extending the root partition residing in a logical volume cr ...

  4. AIX 5L 系统管理技术 —— 存储管理——卷组

    卷组 在安装系统时,就会创建一个rootvg卷组.包含自带硬盘(内置硬盘)和系统逻辑卷,一个系统只能有一个rootvg卷组.一般情况下rootvg卷组最好只包含自带硬盘. 一.创建卷组 在创建卷组之前 ...

  5. 为EXSi5.5上的Centos虚机增加硬盘容量

    宿主机调整 1. 关闭虚机, 2. 检查是否有存在的snapshot, 如果有, 需要删除, 否则不能调整磁盘容量 3. 虚机上编辑配置, 将磁盘容量调大后保存 虚机调整 参考这篇写得非常详细: 点击 ...

  6. A Beginner's Guide To Understanding Convolutional Neural Networks(转)

    A Beginner's Guide To Understanding Convolutional Neural Networks Introduction Convolutional neural ...

  7. paper 48: Latex中如何制作参考文献

    文章写到现在,最后一步就要大功告成了!reference,let's go! 一.用Google来做Latex的bib文件 1. 打开scholar.google.com 2. 定制   Schola ...

  8. (转)A Beginner's Guide To Understanding Convolutional Neural Networks

    Adit Deshpande CS Undergrad at UCLA ('19) Blog About A Beginner's Guide To Understanding Convolution ...

  9. (转)Linux下用mkisofs制作光盘镜像ISO文件

    我们都知道在windows下有winiso可以将光盘制作成光盘镜像ISO文件,在linux下一个命令就搞定了.那就是mkisofs.先看看mkisofs的help. rory@dev:~$ mkiso ...

随机推荐

  1. 洛谷 P3825 [NOI2017]游戏 【2-SAT+状压】

    UOJ和洛谷上能A,bzoj 8ms即WA,现在也不是知道为啥--因为我太弱了 先看数据范围发现d非常小,自然想到了状压. 所以先假装都是只能跑两种车的,这显然就是个2-SAT问题了:对于x场没有hx ...

  2. 【react native】rn踩坑实践——从输入框“们”开始

    因为团队技术栈变更为react native,所以开始写起了rn的代码,虽然rn与react份数同源,但是由于有很多native有关的交互和变动,实际使用还是碰到蛮多问题的,于是便有了这个系列,本来第 ...

  3. 环境变量解释以及在Linux下的环境变量设置

    一.环境变量解释 环境变量是什么? 引用百度百科里面的解释:环境变量是操作系统中一个具有特定名字的对象,它包含了一个或者多个应用程序所将使用到的信息.例如Windows系统中的path环境变量,当要求 ...

  4. [Usaco2017 Open]Modern Art 2

    Description Having become bored with standard 2-dimensional artwork (and also frustrated at others c ...

  5. [USACO 2012 Jan Silver] Delivery Route【拆点】

    传送门:http://www.usaco.org/index.php?page=viewproblem2&cpid=106 这道题还真是完全没思路,真的不知道怎么做,但是看了题解后恍然大悟. ...

  6. A - Add More Zero

    Bryce1010模板 #include <bits/stdc++.h> using namespace std; #define LL long long int main() { in ...

  7. Thinkpad x230设置启动顺序

    设置可以从CD或者USB启动1.F1进入BIOS,Security → Secure Boot ,设置为:Disabled2.Startup → UEFI/Legacy Boot ,设置为:Both( ...

  8. jmeter(六)关联

    话说LoadRunner有的一些功能,比如:参数化.检查点.集合点.关联,Jmeter也都有这些功能,只是功能可能稍弱一些,今天就关联来讲解一下. JMeter的关联方法有两种:后置处理器-正则表达式 ...

  9. 关于c头文件的使用的小记录

    在用visual studio实现数据结构上的一些结构与算法的时候,想在一个工程中建立几个文件,然后主文件可以使用其他文件的函数与变量(比如定义的结构体还有数据结构接口函数).  我们可以利用头文件来 ...

  10. WPF学习08:MVVM 预备知识之COMMAND

    WPF内建的COMMAND是GOF 提出的23种设计模式中,命令模式的实现. 本文是WPF学习07:MVVM 预备知识之数据绑定的后续,将说明实现COMMAND的三个重点:ICommand  Comm ...