链接:

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. 013 Android 实现流水灯功能+自定义控件的样式(可以复用)

    1.介绍 (1)获取屏幕的焦点 android:focusable与android:focusableInTouchMode(获取屏幕焦点) 前者针对在键盘下操作的情况,如果设置为true,则键盘上下 ...

  2. tp5功能模块添加与调试

    在原先完善的功能基础上添加比如导出列表为excel ,一下子把所有属性写全了,出了问题,不好查找问题在哪? 所以遇到这种问题,需要最简单的测试.比如新建一个mysql表内就放一列一行数据.减少代码量, ...

  3. 关于String Json 与其他类型数据转换的总结:

    一:关于自己遇到的坑: 跨域请求获取到 String Json(GSON处理) 数据后处理转换为实体类进行存储: 跨域 return Gson.toJson(map): 通过Http等方法获取请求结果 ...

  4. STM32之SPI时钟相位选择

    SPI的时钟模式分为四种,由SPI_CR1寄存器的两位CPOL,CPHA组合选择. CPOL 如果为1,则时钟的空闲电平为高电平:CPOL 如果为0,则时钟的空闲电平为低电平.空闲电平影响不大. CP ...

  5. 剑指offer33:求按从小到大的顺序的第N个丑数。

    1 题目描述 把只包含质因子2.3和5的数称作丑数(Ugly Number).例如6.8都是丑数,但14不是,因为它包含质因子7. 习惯上我们把1当做是第一个丑数.求按从小到大的顺序的第N个丑数. 2 ...

  6. Mysql之rpm安装5.7版本遇见的问题

    前言:环境是centos7.5的系统,用rpm方式安装mysql5.7 1.由于是centos7.5 所以需要将默认的mariadb给卸载 rpm -qa | grep mariadb 查看下是否有m ...

  7. 20191031:Python取反运算详解

    20191031:Python取反运算详解 取反运算:~3 == 4 1.对于数字 3 =======>转换为二进制表示为011 2.对011取反为100 3.为什么表示-4 a.计算机用补码表 ...

  8. 十九、eMMC驱动框架分析

    一.MMC简介 eMMC在封装中集成了一个控制器,提供标准接口并管理Nand Flash,使得手机厂商就能专注于产品开发的其它部分,并缩短向市场推出产品的时间. 对于我们来说,eMMC就是在Nand ...

  9. docker 实践十:docker 网络管理

    本篇是关于 docker 网络管理的内容,同时也包含了 docker 网络的高级应用. 注:环境为 CentOS7,docker 19.03. docker 网络基础 docker 网络模型 在 do ...

  10. 【转载】Maven入门实践

    Maven 确确实实是个好东西,用来管理项目显得很方便,但是如果是通过 Maven 来远程下载 JAR 包的话,我宿舍的带宽是4兆的,4个人共用,有时候用 Maven 来远程下载 JAR 包会显得很慢 ...