• LightOJ


    import java.io.*;
    import java.math.*;
    import java.util.*;
    import java.util.Scanner;
    //import java.text.*;
    
    public class Main {
    	public static void main(String[] args) {
            Scanner cin = new Scanner (new BufferedInputStream(System.in));
    		//Scanner sc=new Scanner(System.in);
    		int T;
            BigInteger a, b, res;
    		T = cin.nextInt();
    		BigInteger zero = BigInteger.valueOf(0);
            for(int Case = 1; Case <= T; ++ Case){
                a = cin.nextBigInteger();
                b = cin.nextBigInteger();
                if(b.compareTo(zero) < 0){
                    b = zero.subtract(b);
                }
                if(a.compareTo(zero) < 0){
                    a = zero.subtract(a);
                }
                res = a.mod(b);
                if(res.compareTo(zero) == 0){
                    System.out.println("Case " + Case + ": divisible");
                }
                else System.out.println("Case " + Case + ": not divisible");
            }
        }
    }
    
    
    
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<cmath>
    #include<map>
    #include<queue>
    #include<vector>
    #include<string>
    #include<fstream>
    using namespace std;
    #define rep(i, a, n) for(int i = a; i <= n; ++ i)
    #define per(i, a, n) for(int i = n; i >= a; -- i)
    typedef long long ll;
    const int N = 5e5 + 105;
    const int mod = 998244353;
    const double Pi = acos(- 1.0);
    const int INF = 0x3f3f3f3f;
    const int G = 3, Gi = 332748118;
    ll qpow(ll a, ll b) { ll res = 1; while(b){ if(b) res = (res * a) % mod; a = (a * a) % mod; b >>= 1;} return res; }
    ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
    //
    
    
    int T;
    string a;
    ll b, carry;
    
    int main()
    {
        scanf("%d",&T);
        string::iterator top;
        rep(Case,1,T){
            cin>>a>>b;
            top = a.begin();
            carry  = 0;
            if(a[0] == '-') top ++;
            for(; top != a.end(); top ++){
                carry = carry * 10 + *top - '0';
                carry %= b;
            }
            if(carry) printf("Case %d: not divisible
    ",Case);
            else printf("Case %d: divisible
    ",Case);
        }
        return 0;
    }
    
  • 相关阅读:
    Python 包的概念
    EXCEL基础篇(二)
    EXCEL基础篇(一)
    JavaScript(四)Bom
    JavaScript(三)Dom查找、设置标签属性及内容、绑定事件
    erlang并发编程(二)
    OTP&ETS
    erlang中http请求
    erlang证书加密
    erlang并发编程
  • 原文地址:https://www.cnblogs.com/A-sc/p/12820260.html
Copyright © 2020-2023  润新知