链接:

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. PHP 生成公钥私钥,加密解密,签名验签

    test_encry.php <?php //创建私钥,公钥 //create_key(); //要加密内容 $str = "test_str"; //加密 $encrypt ...

  2. nginx配置的记录

    基本使用 语法规则: location [=|~|~*|^~] /uri/ { - } = 开头表示精确匹配 ^~ 开头表示uri以某个常规字符串开头,理解为匹配 url路径即可.nginx不对url ...

  3. Word 下划线无法对齐?用表格替代下划线(论文封面必备)

    1. 前言 在使用Word排版制作合同或者论文封面时,我们可能会使用一些下划线,但是,你在下划线上输入内容后,发现下划线会随着内容而增长,根本无法与上下的下划线对齐.有什么好办法可以解决这一问题呢?其 ...

  4. 剑指offer65:矩阵中的路径(二维数组,二分查找)

    1 题目描述 请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径.路径可以从矩阵中的任意一个格子开始,每一步可以在矩阵中向左,向右,向上,向下移动一个格子.如果一条路径经过了矩 ...

  5. python之numpy和pandas

    一.numpy矩阵的拼接合并 列拼接:np.column_stack() >>> import numpy as np >>> a = np.arange(9).r ...

  6. Vector、ArrayList异同和HTTP请求异同的概括和区别

    今天我所记录的是两个异同的概括: HTTP: 同步请求:提交请求->等待服务器处理->处理完毕返回给客户端  这个期间客户端浏览器只能处于等待状态,得到回应才可以执行下一步操作. 异步请求 ...

  7. 深度学习的激活函数 :sigmoid、tanh、ReLU 、Leaky Relu、RReLU、softsign 、softplus、GELU

    深度学习的激活函数  :sigmoid.tanh.ReLU .Leaky Relu.RReLU.softsign .softplus.GELU 2019-05-06 17:56:43 wamg潇潇 阅 ...

  8. IDEA使用技巧--将本地项目和git远程项目关联

    之前开发没有从头儿搭建过新项目,都是从IDEA配置下项目的git地址,pull代码之后进行开发,提交.这次需要将本地新建的项目push到在git上同样是新建的空项目上去(git上的项目只有工程名和re ...

  9. 五、eureka客户端自动配置

    所有文章 https://www.cnblogs.com/lay2017/p/11908715.html 正文 前面的几篇文章中,我们从eureka Server端的角度看了看eureka的几个核心要 ...

  10. 【转载】使用Response.WriteFile输出文件以及图片

    Response对象是Asp.Net应用程序中非常重要的一个内置对象,其作用为负责将服务器执行好的信息输出给客户端,可以使用Response.WriteFile方法来像客户端输出文件或者图片,输出图片 ...