Big Number
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 7152 Accepted Submission (s): 4934
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.
The problem easier, I promise that B'll be smaller than 100000.
Is it too hard? No, I work it out in the minutes, and my program contains less than lines.
Input the input contains several test cases. Each test case consists of positive integers A and B. The length of A would not exceed, and B would 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
Author IGNATIUS.L
Source Hangzhou Electric ACM Province race training Team tryouts to solve the problem thinking: This problem with the idea of the model and our usual division of the routine is the same. First, then multiply by 10 plus the following number to take the mold, and so on. AC Code:
#include <stdio.h>
#include <string.h>
int main ()
{
char a[1100];
int b,i;
while (scanf ("%s%d", A,&b)!=eof)
{
int len=strlen (a);
int sum=0;
for (i=0;i<len;i++)
{
sum=sum*10+a[i]-' 0 ';
sum=sum%b;
}
printf ("%d\n", sum);
}
return 0;
}