Hangzhou Electric-1212 large number to take the mold

Source: Internet
Author: User
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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.