题目链接:http://lightoj.com/volume_showproblem.php?problem=1214

题意很好懂,同余定理的运用,要是A数被B数整除,那么A%B等于0。而A很大,那我就把A的每一位拆开,比如A是2341,那么2341=2000+300+40+1,然后你懂的...

 #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char str[];
int main()
{
int t;
long long n;
cin >> t;
for(int ca = ; ca <= t ; ca++) {
cin >> str >> n;
int len = strlen(str);
long long temp = , begin = ;
if(str[] == '-')
begin++;
for(int i = begin ; i < len ; i++) {
temp = (temp * % n + (str[i] - '')) % n;
}
cout << "Case " << ca << ": ";
if(!temp)
cout << "divisible\n";
else
cout << "not divisible\n";
}
}

Light oj 1214-Large Division (同余定理)的更多相关文章

  1. light oj 1214 - Large Division

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

  2. 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 ...

  3. (大数 求余) 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 ...

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

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

  5. LightOJ 1214 Large Division

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

  6. LightOJ 1214 Large Division 水题

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

  7. Light OJ 1214

    简单大数模拟题: #include<bits/stdc++.h> using namespace std; typedef long long ll; string Num; vector ...

  8. LightOJ1214 Large Division —— 大数求模

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

  9. LightOJ1214 Large Division 基础数论+同余定理

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

随机推荐

  1. java中List的排序功能的实现

    今天在工作的时候,遇到了List排序的问题,所以总结了一下,与大家分享.Collections.sort排序的时候,用到了Comparator接口下面的compare()方法.下面的小例子中,还用到了 ...

  2. Topcoder SRM 630 (500 floyed 暴力 _builtin_popcount())

    题意:给n个点,保证图联通,给点相连的距离,求一个最多的点,这些点之间的距离都是相同的. 分析: 下面的代码是我们房间第一的大神的,写的很简洁,我的思路和他的一样,但是我不知道错哪了. 思路是暴力枚举 ...

  3. Android系统服务-WindowManager

      WindowManager是Android中一个重要的服务 (Service ).WindowManager Service 是全局的,是唯一的.它将用户的操作,翻译成为指令,发送给呈现在界面上的 ...

  4. POJ 3469 Dual Core CPU (最小割建模)

    题意 现在有n个任务,两个机器A和B,每个任务要么在A上完成,要么在B上完成,而且知道每个任务在A和B机器上完成所需要的费用.然后再给m行,每行 a,b,w三个数字.表示如果a任务和b任务不在同一个机 ...

  5. 利用c#反射实现实体类生成以及数据获取与赋值

    转:http://hi.baidu.com/xyd21c/item/391da2fc8fb351c10dd1c8b8 原有的实体类成员逐个赋值与获取的方法弊端: 1.每次对实体类属性进行赋值时,都要检 ...

  6. Matlab编程实例(1) 移动平均

    MATLAB数字信号处理作业,把自己写的程序发上来..欢迎交流~ QQ 五幺九七九零六四   首先是任意点移动平均: 主程序:mov_average_main.m (运行) 函数:mov_averag ...

  7. Delphi的windows剪切板操作函数

    1. Clipbrd函数 function Clipboard: TClipboard;:若应用程序从未使用过剪贴板,则调用该函数形成新的剪贴板:若之前使用过剪贴板则返回使用过的剪贴板. 属性: As ...

  8. codeforces 696B Puzzles 树形概率计算

    题意:给一棵有根树,从根节点深搜,每次随机走,问每个点的dfs序的期望是多少 分析:对于每一个点,它的所有祖先节点dfs序肯定在它之前,它所在的子树的节点一定在它后面, 剩下的是既不是子树又不是祖先的 ...

  9. container_of

    在学习Linux驱动的过程中,遇到一个宏叫做container_of.该宏定义在include/linux/kernel.h中,首先来贴出它的代码: /** * container_of - cast ...

  10. HDU 1708

    思路 :二位数组维护数目. #include<iostream> #include<stdio.h> #include<stdlib.h> #include< ...