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)