Volume 1. Big Number(uva)
如用到bign类参见大整数加减乘除模板
#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 ;
}
#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 ;
}
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 ;
}
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)的更多相关文章
- Volume 1. Sorting/Searching(uva)
340 - Master-Mind Hints /*读了老半天才把题读懂,读懂了题输出格式没注意,结果re了两次. 题意:先给一串数字S,然后每次给出对应相同数目的的一串数字Si,然后优先统计Si和S ...
- UVA - 10591 Happy Number
Happy Number UVA - 10591 Let the sum of the square of the digits of a positive integer S0 be represe ...
- 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 ...
- AIX 5L 系统管理技术 —— 存储管理——卷组
卷组 在安装系统时,就会创建一个rootvg卷组.包含自带硬盘(内置硬盘)和系统逻辑卷,一个系统只能有一个rootvg卷组.一般情况下rootvg卷组最好只包含自带硬盘. 一.创建卷组 在创建卷组之前 ...
- 为EXSi5.5上的Centos虚机增加硬盘容量
宿主机调整 1. 关闭虚机, 2. 检查是否有存在的snapshot, 如果有, 需要删除, 否则不能调整磁盘容量 3. 虚机上编辑配置, 将磁盘容量调大后保存 虚机调整 参考这篇写得非常详细: 点击 ...
- A Beginner's Guide To Understanding Convolutional Neural Networks(转)
A Beginner's Guide To Understanding Convolutional Neural Networks Introduction Convolutional neural ...
- paper 48: Latex中如何制作参考文献
文章写到现在,最后一步就要大功告成了!reference,let's go! 一.用Google来做Latex的bib文件 1. 打开scholar.google.com 2. 定制 Schola ...
- (转)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 ...
- (转)Linux下用mkisofs制作光盘镜像ISO文件
我们都知道在windows下有winiso可以将光盘制作成光盘镜像ISO文件,在linux下一个命令就搞定了.那就是mkisofs.先看看mkisofs的help. rory@dev:~$ mkiso ...
随机推荐
- bzoj 4817: [Sdoi2017]树点涂色【树链剖分+LCT】
非常妙的一道题. 首先对于操作一"把点x到根节点的路径上所有的点染上一种没有用过的新颜色",长得是不是有点像LCT中的access操作?进而发现,如果把同一颜色的点连起来作为LCT ...
- 51nod 1068 Bash游戏 V3
列出前几项可以发现是个规律题,不要被题目的文字所欺骗,字符串处理10^1000即可 #include <bits/stdc++.h> using namespace std; int ge ...
- 图论/暴力 Codeforces Beta Round #94 (Div. 2 Only) B. Students and Shoelaces
题目传送门 /* 图论/暴力:这是个连通的问题,每一次把所有度数为1的砍掉,把连接的点再砍掉,总之很神奇,不懂:) */ #include <cstdio> #include <cs ...
- GC_CONCURRENT freed 循环不停打印日志
打印类似如下语句: 03-07 19:21:49.562: D/dalvikvm(1677): GC_CONCURRENT freed 2859K, 20% free 12020K/15011K, p ...
- Sqlite数据库中索引的使用、索引的优缺点[转]
原文链接1 原文链接2 3. 索引的种类 1)聚集索引:表中行的物理顺序与键值的逻辑(索引)顺序相同.因为数据的物理顺序只能有一种,所以一张表只能有一个聚集索引.如果一张表没有聚集索引,那么这张表 ...
- ORA-00020: maximum number of processes (300) exceeded
SQL> select count(*) from v$session; COUNT(*)---------- 98 SQL> select count(*) from v$process ...
- hibernate与struts2整合中出现问题以及一级缓存查询数据在业务层问题
直接上问题: org.hibernate.HibernateException: HHH000142: Javassist Enhancement failed: cn.xxx.pojo.Custom ...
- Burp Suite集成sqlmap
本地环境 JDK1.8 Burp Suite 1.7.26 Python2.7 64位安装包 sqlmap zip包 安装python及sqlmap python下载下来默认安装即可,配置系统环境变量 ...
- CAS server 连接mysql的deployerConfigContext.xml配置
1.deployerConfigContext.xml配置 <?xml version="1.0" encoding="UTF-8"?> <b ...
- 【C++】模板简述(二):函数模板
我们上文讲了,模板的引入,我们发现在某种特殊的情况下,必须得通过模板才能完美的解决问题. 本文就来简述一下函数模板的基本使用. 一.函数模板格式 template<typename Param1 ...