码迷,mamicode.com
首页 > 其他好文 > 详细

Light OJ 1214

时间:2015-10-28 22:33:37      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

简单大数模拟题;

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string Num;
vector<ll> Big;

ll MOD(vector<ll> Big, ll m)
{
    ll ret = 0;
    for(int i = 0; i < Big.size(); ++i)
    {
        ret = ret * 10 + Big[i];
        ret = ret % m;
    }
    return ret;
}

int main()
{
    ll t, n;
    scanf("%lld",&t);
    for(int kase = 1; kase <= t; ++kase)
    {
        cin >> Num >> n;
        Big.clear();
        for(int i = 0; i < Num.length(); ++i)
        {
            if(Num[i] >= ‘0‘ && Num[i] <= ‘9‘)
                Big.push_back(Num[i] - ‘0‘);
        }
        if(n < 0) n = -n;
        int ans = MOD(Big, n);
        printf("Case %d: %s\n",kase, ans == 0 ? "divisible" : "not divisible");
    }
}

 

Light OJ 1214

标签:

原文地址:http://www.cnblogs.com/aoxuets/p/4918670.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!