- #include <stdio.h>
- int main()
- {
- long long int tst, i, j, b, dcml;
- char a[1000];
- scanf("%lld", &tst);
- for(i=1; i<=tst; i++)
- {
- long long int mod_a=0, div_a=0;
- scanf("%s", a);
- scanf("%lld", &b);
- j=0;
- if(a[0]=='-') j=1;
- while(a[j])
- {
- dcml = a[j] - 48;
- div_a+=dcml;
- mod_a = div_a%b;
- div_a= mod_a*10;
- j++;
- }
- if(mod_a==0) printf("Case %lld: divisible\n", i);
- else printf("Case %lld: not divisible\n", i);
- }
- return 0;
- }
- /*
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- int ts;
- scanf("%d", &ts);
- for(int p = 1; p <= ts; p++){
- char s[1000];
- int b;
- int i = 0;
- scanf("%s",s);
- scanf("%d", &b);
- b = abs(b);
- int a = 0;
- if(s[0] == '-') i++;
- while(s[i]){
- a = ((a*10) + (s[i] - '0'))%b;
- }
- if(!b) printf("Case %d: divisible\n", p);
- else printf("Case %d: not divisible\n", p);
- }
- return 0;
- }
- */
Friday 28 July 2017
Lightoj 1214 - Large Division
Subscribe to:
Post Comments (Atom)
Most Featured Post
Lightoj 1159 - Batman
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
-
Problem link: Problem Analysis: It is actually a basic Bisection problem , as we can see here we can not actually find a formula fo...
-
http://lightoj.com/volume_showproblem.php?problem=1382 Problem analysis: This is a rare problem i wrote about so far. After much strugg...
No comments:
Post a Comment