链接:

https://vjudge.net/problem/LightOJ-1214

题意:

Given two integers, a and b, you should check whether a is divisible by b or not. We know that an integer a is divisible by an integer b if and only if there exists an integer c such that a = b * c.

思路:

考虑同余式 \((a \ast 10) \% m + b \% m = a \% m\)

链接:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map> using namespace std;
typedef long long LL;
const int INF = 1e9; const int MAXN = 1e6+10;
const int MOD = 1e9+7; char s[500]; int main()
{
int t, cnt = 0;
LL mod;
scanf("%d", &t);
while(t--)
{
printf("Case %d: ", ++cnt);
scanf("%s %lld", s, &mod);
mod = abs(mod);
LL m = (s[0] != '-')?(s[0]-'0'):(s[1]-'0');
int len = strlen(s);
for (int i = (s[0] != '-')?1:2;i < len;i++)
m = (m*10%mod+(s[i]-'0'))%mod;
if (m == 0)
puts("divisible");
else
puts("not divisible");
} return 0;
}

LightOJ - 1214-Large Division(数学,同余)的更多相关文章

  1. LightOJ 1214 Large Division

    Large Division Given two integers, a and b, you should check whether a is divisible by b or not. We ...

  2. LightOJ 1214 Large Division 水题

    java有大数模板 import java.util.Scanner; import java.math.*; public class Main { public static void main( ...

  3. light oj 1214 - Large Division

    1214 - Large Division   PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB G ...

  4. light oj 1214 - Large Division 大数除法

    1214 - Large Division Given two integers, a and b, you should check whether a is divisible by b or n ...

  5. 1214 - Large Division -- LightOj(大数取余)

    http://lightoj.com/volume_showproblem.php?problem=1214 这就是一道简单的大数取余. 还想还用到了同余定理: 所谓的同余,顾名思义,就是许多的数被一 ...

  6. Large Division (大数求余)

    Given two integers, a and b, you should check whether a is divisible by b or not. We know that an in ...

  7. lightoj 1214

    lightoj 1214 Large Division  (大数除法) 链接:http://www.lightoj.com/volume_showproblem.php?problem=1214 题意 ...

  8. LightOJ1214 Large Division —— 大数求模

    题目链接:https://vjudge.net/problem/LightOJ-1214 1214 - Large Division    PDF (English) Statistics Forum ...

  9. (大数 求余) Large Division Light OJ 1214

    Large Division Given two integers, a and b, you should check whether a is divisible by b or not. We ...

  10. K - Large Division 判断a是否是b的倍数。 a (-10^200 ≤ a ≤ 10^200) and b (|b| > 0, b fits into a 32 bit signed integer). 思路:取余;

    /** 题目:K - Large Division 链接:https://vjudge.net/contest/154246#problem/K 题意:判断a是否是b的倍数. a (-10^200 ≤ ...

随机推荐

  1. 【剑指offer】面试题 42. 连续子数组的最大和

    面试题 42. 连续子数组的最大和 NowCoder 题目描述 输入一个整型数组,数组里有正数也有负数.数组中一个或连续的多个整数组成一个子数组.求所有子数组的和的最大值. 示例: 输入: [-2,1 ...

  2. 树莓派上跑.NET的segment fault错误

    答案:树莓派1和树莓派zero是不支持的,原因是.net需要arm v7 详情看这里 可以用 cat /proc/cpuinfo | grep 'model name' |uniq 看一下cpu

  3. InnoDB一定会在索引中加上主键吗?

    先回答问题,是的. 故事, 如下图,今天查看慢sql发现同事在建索引的时候竟然包含了主键,第一感觉这种姿势不对. 我记得很多文章都说过二级索引会自动带上主键,为什么还有人这么操作,后来差了些资料,如下 ...

  4. Hystrix【异常机制处理】

    在之前的老版本中,feign中是默认开启hystrix的,从新版本中默认已经关闭了,如果要通过FeignClient调用服务并开启hystrix的话,需要自定义开启,即:feign.hystrix.e ...

  5. 2018ACM-ICPC亚洲区域赛南京站I题Magic Potion(网络流)

    http://codeforces.com/gym/101981/attachments 题意:有n个英雄,m个敌人,k瓶药剂,给出每个英雄可以消灭的敌人的编号.每个英雄只能消灭一个敌人,但每个英雄只 ...

  6. PHP中类的继承与方法重写

    php中类的继承与方法重写,欢迎大神补充指点! <?php namespace _1009; class Demo5 { //实例属性 public $product; public $pric ...

  7. Map、Set的基本概括

    Map: 在运用map和set 集合之前首先要弄清楚它们的基本定义是什么. 简介:map是一种关联式容器,但是她储存方式是以键值对(key/value)存在的. Map用法: 定义Map集合并往集合中 ...

  8. Aop 打印参数日志时,出现参数序列化异常。It is illegal to call this method if the current request is not in asynchron

    错误信息: nested exception is java.lang.IllegalStateException: It is illegal to call this method if the ...

  9. java EE学习之数据库操作

    jdbc开发流程 注册驱动 建立连接(Connection) 创建运行SQL的语句(Statement) 运行语句 处理运行结果(ResultSet) 释放资源 注冊驱动有三种方式: Class.fo ...

  10. ClickOnce 部署 API 以编程方式检查应用程序更新

    private void InstallUpdateSyncWithInfo() { UpdateCheckInfo info = null; if (ApplicationDeployment.Is ...