Advertisement
nightwing_808

divisible or not

Feb 8th, 2023
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | Source Code | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. int main()
  5. {
  6.     unsigned long long int t,a,b,d,e;
  7.     scanf("%llu",&t);
  8.     for (int i=1;i<=t;i++)
  9.     {
  10.         scanf("%llu%llu",&a,&b);
  11.         a=abs(a);
  12.         b=abs(b);
  13.         int s=0;
  14.         e=a;
  15.         while (e!=0)
  16.         {
  17.             s++;
  18.             e=e/10;
  19.         }
  20.         int arr[s];
  21.         for (int j=s-1;j>=0;j--)
  22.         {
  23.             arr[j]=a%10;
  24.             a=a/10;
  25.         }
  26.         long long int c=0;
  27.         for (int j=0;j<s;j++)
  28.         {
  29.             c=(c*10)+arr[j];
  30.             c=c%b;
  31.         }
  32.         if (c==0) printf("Case %d: divisible\n",i);
  33.         else printf("Case %d: not divisible\n",i);
  34.     }
  35.     return 0;
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement