题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1573 X问题 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5012    Accepted Submission(s): 1667 Problem Description 求在小于等于N的正整数中有多少个X满足:X mod a[0] =…
Biorhythms Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2408    Accepted Submission(s): 1053 Problem Description Some people believe that there are three cycles in a person's life that start…
X问题 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3295    Accepted Submission(s): 1068 Problem Description 求在小于等于N的正整数中有多少个X满足:X mod a[0] = b[0], X mod a[1] = b[1], X mod a[2] = b[2], -, X mo…
F - Strange Way to Express Integers Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%I64d & %I64u Submit Status Description Elina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers.…
Strange Way to Express Integers Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 17877   Accepted: 6021 Description Elina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is…
<题目链接> 题目大意: 给你一些模数和余数,让你求出满足这些要求的最小的数的值. 解题分析: 中国剩余定理(模数不一定互质)模板题 #include<stdio.h> using namespace std; #define ll long long ll A[],B[];//B[i]为余数 ll dg,ans;//dg为A[i]的最小公倍数 ans 为最小解 void exgcd(ll a, ll b, ll &d, ll&x, ll &y) { ; y…
二进制枚举+容斥原理+中国剩余定理 #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<cmath> using namespace std; #define MAXN 20 typedef long long LL; int n; int s[MAXN]; LL a[MAXN], m[MAXN]; //a是余数,m是除数 LL ex…
我理解的中国剩余定理的含义是:给定一个数除以一系列互素的数${p_1}, \cdots ,{p_n}$的余数,那么这个数除以这组素数之积($N = {p_1} \times  \cdots  \times {p_n}$)的余数也确定了,反之亦然. 用表达式表示如下: \[\begin{array}{l}x \equiv {a_1}(\bmod {p_1})\\{\rm{     }} \vdots \\x \equiv {a_n}(\bmod {p_n})\end{array}\] 那么任何满足…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5768 题目大意: T组数据,求L~R中满足:1.是7的倍数,2.对n个素数有 %pi!=ai  的数的个数. 题目思路: [中国剩余定理][容斥原理][快速乘法][数论] 因为都是素数所以两两互素,满足中国剩余定理的条件. 把7加到素数中,a=0,这样就变成解n+1个同余方程的通解(最小解).之后算L~R中有多少解. 但是由于中国剩余定理的条件是同时成立的,而题目是或的关系,所以要用容斥原理叠加删…
题目链接: http://poj.org/problem?id=1006 http://acm.hdu.edu.cn/showproblem.php?pid=1370 题目大意: (X+d)%23=a1,(X+d)%28=a2,(X+d)%33=a3,给定a1,a2,a3,d,求最小的X. 题目思路: [中国剩余定理] 23,28,33互素,可以套中国剩余定理. 也可以直接手算逆元. 33×28×a模23的逆元为8,则33×28×8=5544: 23×33×b模28的逆元为19,则23×33×1…