链接:

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. 《Mysql - 读写分离有哪些坑?》

    一:读写分离 - 概念 -  读写分离的主要目标就是分摊主库的压力. - 基本架构 -     -  二:两种读写分离的架构特点 - 客户端直连方案 - 因为少了一层 proxy 转发,所以查询性能稍 ...

  2. JUC之AbstractQueuedSynchronizer原理分析 - 独占/共享模式

    1. 简介 AbstractQueuedSynchronizer (抽象队列同步器,以下简称 AQS)出现在 JDK 1.5 中,由大师 Doug Lea 所创作.AQS 是很多同步器的基础框架. R ...

  3. synchronized的不足与redis分布式锁的使用

    这里是一个简单模拟秒杀的逻辑,stock和orders为两个Map,分别模拟库存表和订单表 public void orderProductMockDiffUser(String productId) ...

  4. STL源码剖析——iterators与trait编程#4 iterator源码

    在前两节介绍了迭代器的五个相应类型,并讲述如何利用traits机制提取迭代器的类型,但始终是把iteartor_traits类分割开来讨论,这影响我们的理解,本节将给出iteator的部分源码,里面涵 ...

  5. Python22之lambda表达式

    一.Lambda表达式的概念和意义 lambda表达式有称为隐函数,它的定义过程由形参和要返回的表达式组成,它相对于一般函数而言具有以下优势: 1.免去了函数定义的过程,代码变得更加精简 2.省却函数 ...

  6. Arm-Linux 移植 mtd-utils 1.x

    有关文章:<mtd-utils 的 使用> 背景: 关于在公司的生产环境有关.不希望每次都在uboot下面做nand flash 的烧写:也觉得使用U盘升级的方法比较慢,而且有关的驱动不是 ...

  7. VMWare linux虚拟机(centos没有GUI)联网(NAT模式)

    使用yum list命令查看是否能连上网. 不能联网,需要对centos进行网络配置.但在此之前,需要: 1. 虚拟机网络连接方式设置成NAT. 2. window系统下的两个服务VMwareDHCP ...

  8. 记一次关闭Hadoop时no namenode to stop异常

    记一次关闭Hadoop时no namenode to stop异常 ​ 在自己的虚拟机环境上跑着hadoop集群,一直正常运行着,不用的时候直接挂起虚拟机,今天需要做些调整,但是发现集群突然无法正常关 ...

  9. PG SQL funcation

    create extension IF NOT EXISTS "uuid-ossp" ; --select uuid_generate_v4(); --select current ...

  10. CVPR2014: DeepID解读

    上周五就要发的,拖........拖.......拖到现在,文中有不准确的地方,欢迎批评指正. DeepID是一种特征提取的算法,由港中文汤晓鸥团队于2014年提出,发表于CVPR2014.其应用领域 ...