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

424 - Integer Inquiry

  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4. #include <cstdio>
  5. #include <cstdlib>
  6. #define N 10050
  7. using namespace std;
  8. string s;
  9. int ans[N];
  10. int main()
  11. {
  12. int i, j;
  13. while (cin>>s, s[] != '')
  14. {
  15. for (i = s.length() - , j = ; i >= ; i--, j++)
  16. ans[j] += (s[i] - '');
  17. }
  18. for (i = ; i < N - ; i++)
  19. {
  20. ans[i + ] += ans[i] / ;
  21. ans[i] %= ;
  22. }
  23. i = N - ;
  24. while (!ans[i] && i > )
  25. i--;
  26. while (i >= )
  27. cout<<ans[i--];
  28. cout<<endl;
  29. return ;
  30. }

10106 - Product

  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4. #include <algorithm>
  5. #include <cstdio>
  6. #include <cstdlib>
  7. #define N 550
  8. using namespace std;
  9. int ans[N];
  10. string s1, s2;
  11.  
  12. int main()
  13. {
  14. int i, j, ls1, ls2, len;//tmp表示进位
  15. while (cin>>s1>>s2)
  16. {
  17. ls1 = s1.length() - ;
  18. ls2 = s2.length() - ;
  19. len = ls1 + ls2;
  20. memset(ans, , sizeof(ans));
  21. for (i = ls1; i >= ; i--)
  22. for (j = ls2; j >= ; j--)
  23. {
  24. ans[len - (i + j)] += (s1[i] - '') * (s2[j] - '');
  25. }
  26. len++;
  27. for (i = ; i < len; i++)
  28. {
  29. ans[i + ] += ans[i] / ;
  30. ans[i] = ans[i] % ;
  31. }
  32. while (!ans[len] && len > )//去除前导0
  33. len--;
  34. for (; len >= ; len--)
  35. cout<<ans[len];
  36. cout<<endl;
  37. }
  38. return ;
  39. }

465 - Overflow

  1. int main()
  2. {
  3. //ifstream cin("test.in");
  4. bign a, b, c;
  5. char ch;
  6. bign d = INT_MAX;
  7. string sa, sb;
  8. while (cin>>sa>>ch>>sb)
  9. {
  10.  
  11. cout<<sa<<' '<<ch<<' '<<sb<<endl;
  12. a = sa;
  13. b = sb;
  14. if (d < a)
  15. cout<<"first number too big"<<endl;
  16. if (d < b)
  17. cout<<"second number too big"<<endl;
  18. if (ch == '+')
  19. c = a + b;
  20. else
  21. c = a * b;
  22. cout<<c<<endl;
  23. if (d < c)
  24. cout<<"result too big"<<endl;
  25. }
  26. return ;
  27. }

748 - Exponentiation

  1. int main()
  2. {
  3. string sa, sb;
  4. bign a, b;
  5. int p, n, i;
  6. while (cin>>sa>>n)
  7. {
  8. p = ;
  9. while (sa[p] != '.')
  10. p++;
  11. sa.erase(sa.begin() + p);
  12. a = sa;
  13. b = a ^ n;
  14. sb = b.to_str();
  15. p = ( - p) * n;
  16. for (i = b.length(); i < p; i++)
  17. sb += '';
  18. sb.insert(sb.begin() + p, '.');
  19. p = ;
  20. while (sb[p] == '')
  21. p++;
  22. for (i = sb.length() - ; i >= p; i--)
  23. cout<<sb[i];
  24. cout<<endl;
  25. }
  26. return ;
  27. }

10494 - If We Were a Child Again

  1. int main()
  2. {
  3. //string sa, sb;
  4. bign a, b, c;
  5. char ch;
  6. while (cin>>a>>ch>>b)
  7. {
  8. if (ch == '/')
  9. c = a / b;
  10. else
  11. c = a % b;
  12. cout<<c<<endl;
  13. }
  14. return ;
  15. }

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. zoj 2760 How Many Shortest Path【最大流】

    不重叠最短路计数. 先弗洛伊德求一遍两两距离(其实spfa或者迪杰斯特拉会更快但是没必要懒得写),然后设dis为st最短距离,把满足a[s][u]+b[u][v]+a[v][t]==dis的边(u,v ...

  2. 4800: [Ceoi2015]Ice Hockey World Championship(折半搜索)

    4800: [Ceoi2015]Ice Hockey World Championship Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 622  S ...

  3. LuoguP1314 聪明的质检员 【二分答案/前缀和】

    美丽的题号预示着什么... 描述 小 T 是一名质量监督员,最近负责检验一批矿产的质量.这批矿产共有n个矿石,从1到n逐一编号,每个矿石都有自己的重量wi以及价值vi.检验矿产的流程是: 1.给定m个 ...

  4. Ubuntu 18 通过ssh连接远程服务器

    ps -e | grep ssh 查看自己的Ubuntu是否开启ssh服务,如果我们要连其他的,那需要有 ssh-client的进程 如果我们的作为主机,那需要有sshd的进程 相应的安装方法: cl ...

  5. bzoj258 [USACO 2012 Jan Gold] Bovine Alliance【巧妙】

    传送门1:http://www.usaco.org/index.php?page=viewproblem2&cpid=111 传送门2:http://www.lydsy.com/JudgeOn ...

  6. 关于python深度学习网站

      大数据文摘作品,转载要求见文末 编译团队|姚佳灵 裴迅 简介 ▼ 深度学习,是人工智能领域的一个突出的话题,被众人关注已经有相当长的一段时间了.它备受关注是因为在计算机视觉(Computer Vi ...

  7. android 系统的时间间隔和睡眠用哪个?

    原文 : https://developer.android.com/reference/android/os/SystemClock.html SystemClock.elapsedRealtime ...

  8. 大小写 unix and windows

    如果你没有使用工具, 只是sqlplus对大小写不敏感. 如果你要给sql传递参数,且在windows下面就不需要考虑.如果是aix系统,最好写一样.

  9. C#_JDBC连接数据库

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  10. java获取公网ip以及物理地址和代理商

    package ipconfig; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStr ...