hdoj 1212Big Number(大数取模)
2015-09-19 11:09
357 查看
Big Number
[b]Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6148 Accepted Submission(s): 4295
[/b]
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模板: [code]for(i=0;i<len;i++) { sum=(sum*10+(s[i]-'0')%m)%m; }代码: #include<stdio.h>
#include<string.h>
int main()
{
int i,m;
char s[1000];
while(scanf("%s%d",s,&m)!=EOF)
{
int sum=0;
int len=strlen(s);
for(i=0;i<len;i++)
{
sum=(sum*10+(s[i]-'0')%m)%m;
}
printf("%d\n",sum);
}
}[/code]
相关文章推荐
- Android任意处代码跳转固定activity 的思路
- ftp的get命令
- 技术人生:故事之十三 CGI,ASP?
- Android Api Demos登顶之路(七十三)Graphics-->Compass
- 【区间查询&遍历建树】2015 ACMICPC Asia Regional Changchun Online 1007&1008
- 自己对git的认识。
- Java记录 -39- 生成指定范围内随机数
- iOS中的Frame和Bounds
- 如何从一个表的数据复制到另一个表里面(二个库不在同一台电脑上)
- 一道google面试题
- HTTP和socket的区别
- 使用xocde7.0你必须要注意的几件事
- MySQL 5.6 for Windows 解压缩版配置安装
- 程序员不常用Linux命令集
- jdbc连接数据库异常对只转发结果集的无效操作:last
- 面试、笔试题记录
- Extjs中设置只读的样式问题
- oracle环境配置与使用指南
- 软工文档总结
- 如何使用Eclipse API 提供 org.eclipse.wst.wsdl 要解决阅读WSDL档?