Lightoj 1214-large Division (large number of surplus)

Source: Internet
Author: User

1214-large Division
PDF (中文版) Statistics Forum
Time Limit: 1 second (s) Memory Limit: MB

Given-Integers, a and b, you should checkwhethera is divisible by b or not. We knowA integer ais divisible by an integer b if and only if there exists an integerCs Uch that a = b * C.

Input

Input starts with an integer T (≤525), denoting the number of test cases.

Starts with a line containing-integers a ( -10200≤a≤10200) and B (|b| >0, B fits into a 32 Bit signed integer). Numbers would not contain leadingzeroes.

Output

For each case, print the case number first. Then print ' divisible 'ifa was divisible by b. Otherwise print ' not divisible '.

Sample Input Output for Sample Input

6

101 101

0 67

-101 101

7678123668327637674887634 101

11010000000000000000 256

-202202202202000202202202-101

Case 1:divisible

Case 2:divisible

Case 3:divisible

Case 4:not Divisible

Case 5:divisible

Case 6:divisible

Double type can not take redundancy;


#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #define LL Long Longusing namespace Std;char s[400];int main () {    LL n,m,i,x,y;    LL CLA;    bool BJ;    scanf ("%lld", &CLA);    for (int gr=1; gr<=cla; gr++)    {        bj=true;        scanf ("%s%lld", s,&m);        printf ("Case%LLD:", GR);        x=0;        For (I=0;i<strlen (s); i++)//A large number of the type of an integer, handling the words enumerated by a large number of each character for the remainder        {            if (s[i]== '-')            continue;            x= (x*10+s[i]-' 0 ')%m;        }        if (!x)//Whether the final result is 0            printf ("divisible\n");        else            printf ("Not divisible\n");    }    return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Lightoj 1214-large Division (large number of surplus)

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.