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 ...
随机推荐
- zoj 2760 How Many Shortest Path【最大流】
不重叠最短路计数. 先弗洛伊德求一遍两两距离(其实spfa或者迪杰斯特拉会更快但是没必要懒得写),然后设dis为st最短距离,把满足a[s][u]+b[u][v]+a[v][t]==dis的边(u,v ...
- 4800: [Ceoi2015]Ice Hockey World Championship(折半搜索)
4800: [Ceoi2015]Ice Hockey World Championship Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 622 S ...
- LuoguP1314 聪明的质检员 【二分答案/前缀和】
美丽的题号预示着什么... 描述 小 T 是一名质量监督员,最近负责检验一批矿产的质量.这批矿产共有n个矿石,从1到n逐一编号,每个矿石都有自己的重量wi以及价值vi.检验矿产的流程是: 1.给定m个 ...
- Ubuntu 18 通过ssh连接远程服务器
ps -e | grep ssh 查看自己的Ubuntu是否开启ssh服务,如果我们要连其他的,那需要有 ssh-client的进程 如果我们的作为主机,那需要有sshd的进程 相应的安装方法: cl ...
- bzoj258 [USACO 2012 Jan Gold] Bovine Alliance【巧妙】
传送门1:http://www.usaco.org/index.php?page=viewproblem2&cpid=111 传送门2:http://www.lydsy.com/JudgeOn ...
- 关于python深度学习网站
大数据文摘作品,转载要求见文末 编译团队|姚佳灵 裴迅 简介 ▼ 深度学习,是人工智能领域的一个突出的话题,被众人关注已经有相当长的一段时间了.它备受关注是因为在计算机视觉(Computer Vi ...
- android 系统的时间间隔和睡眠用哪个?
原文 : https://developer.android.com/reference/android/os/SystemClock.html SystemClock.elapsedRealtime ...
- 大小写 unix and windows
如果你没有使用工具, 只是sqlplus对大小写不敏感. 如果你要给sql传递参数,且在windows下面就不需要考虑.如果是aix系统,最好写一样.
- C#_JDBC连接数据库
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- java获取公网ip以及物理地址和代理商
package ipconfig; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStr ...