If We Were a Child Again
来源:互联网 发布:客户地图软件 编辑:程序博客网 时间:2024/05/20 06:10
If We Were a Child Again
大意:
计算给出数据的商或余
要点:
借鉴了前辈思想, 采用了LONG LONG来存储数据
由于限制除数的最大范围为INT型的最大值,所以余数可以用LONG LONG 型来存储
由高位依次往地位取商,使得除法运算始终不会溢出LONG LONG型的最大值
代码:
#include <iostream>#include <string>using namespace std;string x, sign;long long y, mod;int divi[10000];int main(){long long i, j;while (cin >> x >> sign >> y){mod = 0;long long leng = x.length();for (i = 0; i < leng; i++){mod = mod * 10 + x[i] - '0';divi[i] = mod / y;mod = mod % y;}if (sign == "%")cout << mod;else{bool flag = false;for (j = 0; j < i; j++){if (divi[j] > 0)flag = true;if (flag)cout << divi[j];}if (!flag)cout << "0";}cout << endl;}return 0;}
0 0
- 10494 If We Were a Child Again
- uva10494 - If We Were a Child Again
- 10494 - If We Were a Child Again
- 5312 If We Were a Child Again
- 10494 - If We Were a Child Again
- If We Were a Child Again
- If We Were a Child Again
- 10494 - If We Were a Child Again
- uva10494 if we were a child again
- uva If We Were a Child Again
- uva10494 - If We Were a Child Again
- If We Were a Child Again
- If We Were a Child Again
- UVA10494 If We Were a Child Again
- UVA10494 - If We Were a Child Again
- UVa UVa 10494 - If We Were a Child Again
- 10494 - If We Were a Child Again大总结
- UVaOJ 10494 - If We Were a Child Again
- 组合数
- Android TextView的各种属性
- Ubuntu下mysql数据库插入中文出现乱码的解决方法
- C 的 "%s"对应以'\0'结尾的字符串
- Git命令参考手册(文本版)
- If We Were a Child Again
- Petrel 2014 图形工作站应用方案
- linux内核分析笔记----中断和中断处理程序
- Algorithms—61.Rotate List
- Oracle 列转行函数 Listagg()示例
- ftp error "425 Use PORT or PASV first."
- Num 16: HDOJ: 题目1061 : Rightmost Digit [ 求个位数 ] [ 快速幂算法 ]
- Android利用Fiddler进行网络数据抓包
- 返回函数的JavaScript函数