HDU
来源:互联网 发布:ps如何把图片矩阵排列 编辑:程序博客网 时间:2024/06/06 09:37
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"stdio.h"#include "string.h"#include "math.h"int main(){ char ai[1000]; _int64 B,n,num,yu,i,j; while(scanf("%s",ai)==1) { getchar(); scanf("%I64d",&B); yu=0; n=strlen(ai); for (i=0;i<=n-6;i=i+6) { num=yu*1000000+(ai[i]-48)*100000+(ai[i+1]-48)*10000+(ai[i+2]-48)*1000+(ai[i+3]-48)*100+(ai[i+4]-48)*10+ai[i+5]-48; yu=num%B; } num=0; for(j=i;j<n;j++) { num=num+(ai[j]-48)*pow(10,(n-j-1)); } num=num+yu*pow(10,(n-i)); printf("%I64d\n",num%B); } return 0;}
0 0
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- hdu
- HDU
- Java学习之Iterator(迭代器)的一般用法
- pandas进行数据的交集与并集方式的数据合并
- 遍历(也称迭代)容器的4种常用方式
- BFS:HDU-1242-Rescue(带守卫的迷宫问题)(优先队列)
- 【JZOJ5055】【GDOI2017模拟二试4.12】树上路径
- HDU
- Activity切换(带参数)
- TestController
- Java应用集群下的定时任务处理方案(mysql)
- 企业所得税
- django Rest Framework 系列 1
- CodeForces
- 有关Java Collections的几个常见问题
- sql优化