hdu Big Number
来源:互联网 发布:加速器for mac 编辑:程序博客网 时间:2024/05/09 16:20
简单题
Problem Description
As we know, Big Number is always troublesome. But it's really important in our ACM. And today, your task is to write a program to calculate A mod B.
To make the problem easier, I promise that B will be smaller than 100000.
Is it too hard? No, I work it out in 10 minutes, and my program contains less than 25 lines.
Input
The input contains several test cases. Each test case consists of two positive integers A and B. The length of A will not exceed 1000, and B will be smaller than 100000. Process to the end of file.
Output
For each test case, you have to ouput the result of A mod B.
Sample Input
2 3
12 7
152455856554521 3250
Sample Output
2
5
1521
代码:
#include <iostream>#include <string>#include <iomanip>#include <algorithm>#include <cmath>#include <cstring> #include <stdio.h>#include <iomanip> using namespace std;int cmp(char c){if(c=='0') return 0;else if(c=='1') return 1;else if(c=='2') return 2;else if(c=='3') return 3;else if(c=='4') return 4;else if(c=='5') return 5;else if(c=='6') return 6;else if(c=='7') return 7;else if(c=='8') return 8;else if(c=='9') return 9;}int main(){string st;int n,sum;while(cin>>st>>n){ sum=0;for(int i=0;i<st.size();i++){sum=sum*10+cmp(st[i]);sum=sum%n;}cout<<sum<<endl;}return 0;}
0 0
- hdu 1018 Big Number
- HDU 1018 Big Number
- HDU 1018 - Big Number
- hdu 1212 Big Number
- HDU 1212 ( Big Number )
- hdu 1018 Big Number
- hdu 1018 Big Number
- hdu Big Number
- HDU 1018 Big Number
- HDU 1018 Big Number
- HDU 1018 Big Number
- hdu 1018 Big Number
- hdu 1018 Big Number
- HDU Big Number
- HDU 1018 Big Number
- hdu 1018 - Big Number
- HDU 1018 Big Number
- HDU 1018 Big Number
- 与Servlet相关类的层次结构及HttpServlet的生命周期
- Linux C连接Mysql数据库
- js获取当前页面的url
- Android BroadcastReceiver
- FakeID签名漏洞分析及利用(Google Bug 13678484)
- hdu Big Number
- 光栅化
- 安装完oracle后eclipse不能启动
- [Spring] - Property注入
- 如何使用Instruments诊断App(Swift版):起步
- Lua 初识之面向对象 - 十四
- Objc-C 知识点回顾 三 继承
- 最全Pycharm教程(11)——Pycharm调试器之断点篇
- java RSA加密解密实现