标签:
简单大数模拟题;
#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"); } }
标签:
原文地址:http://www.cnblogs.com/aoxuets/p/4918670.html