cf1056B. Divide Candies(数论 剩余系)】的更多相关文章

题意 题目链接 求满足\(i^2 + j^2 \% M = 0\)的数对\((i, j)\)的个数,\(1 \leqslant i, j \leqslant 10^9, M \leqslant 1000\) Sol 发这篇博客的目的就是为了证明一下我到底有多菜. mdzz小学组水题我想了40min都没想出来.这要是出在NOIP 2019的话估计我又要做不出Day1T1了.. \(i^2 + j^2 \% M = i \% M * i \% M + j \% M * j \% M\) 枚举剩余系即…
Arkady and his friends love playing checkers on an n×nn×n field. The rows and the columns of the field are enumerated from 11 to nn. The friends have recently won a championship, so Arkady wants to please them with some candies. Remembering an old pa…
题目链接 分析一下题意可以得到题目要求的是满足下面这个 公式的不同的i,ji,ji,j的方案数; 即(i2+j2)mod   m=0 (n ≤ i,j≤ n)(i^2+j^2)\mod \ m =0\ ( n\ \leq\ i,j\leq \ n)(i2+j2)mod m=0 (n ≤ i,j≤ n). 当然n2n^2n2是可以解决的,但是数据范围不允许我们这么做,于是我们可以换个思路,如果一个数iii满足 imod &a…
https://codeforces.com/contest/1056/problem/B 题意:输入n,m    求((a*a)+(b*b))%m==0的(a,b)种数(1<=a,b<=n) (n<=1e9,m<=1000) 题解:由于a,b的数量级很大,而m的数量级很小,又因为求((a*a)+(b*b))%m==0,即求((a%m*a%m)+(b%m*b%m))%m==0满足要求的a,b对数,也就是求a%m,b%m的平方分别取模后相加为0或者m的a,b对数,由于此时问题只和a%…
关于模和互质,很好的题目 /* n两个质因子 x,y有 ax+by=n-1 ax+by=n-1 ax+1+by=n y|ax+1 gcd(x,y)=1 ax%y,a取[1,y-1],就会有[1,y-1]个不同的值 其中 必定有y-1 所以y|ax+1 ax+1<=(y-1)x+1=xy-y+1<=n,所以必定存在a,b */ #include<bits/stdc++.h> using namespace std; #define ll long long ll n; ll prim…
A. Determine Line Water. #include <bits/stdc++.h> using namespace std; ]; int main() { while (scanf("%d", &n) != EOF) { memset(vis, , sizeof vis); , tot, x; i <= n; ++i) { scanf("%d", &tot); while (tot--) { scanf("…
前言:程不在长,能过则行.码不在多,无虫则灵.斯是信竞,惟吾爆零.线段维护快,树状跳的勤.数论剩余系,图论前向星.无数竞之推理,无物竞之劳形.大佬楼教主,超奆姚期智,神犇云:您太强了. 早上5:00就醒了,根本睡不着 5:30,在床上翻来覆去睡不着,只好起来洗了个澡 8:30开始比赛,状态不是很好,有点困 T1 简要题意:求\(l,r\)之间模 \(n\) 的最大数. 刚看到这道题,我没想那么多,直接上机就打,用了一个双重循环嵌套,打完再一仔细看题,才发现 这就是一道数学题 看了一眼数据范围 \…
Who Gets the Most Candies? Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 10373   Accepted: 3224 Case Time Limit: 2000MS Description N children are sitting in a circle to play a game. The children are numbered from 1 to N in clockwise…
注:转载本文须标明出处. 原文链接https://www.cnblogs.com/zhouzhendong/p/Number-theory.html 数论算法 剩余系相关 学习笔记 (基础回顾,(ex)CRT,(ex)lucas,(ex)BSGS,原根与指标入门,高次剩余,Miller_Robin+Pollard_Rho) 本文概要 1. 基础回顾 2. 中国剩余定理 (CRT) 及其扩展 3. 卢卡斯定理 (lucas) 及其扩展 4. 大步小步算法 (BSGS) 及其扩展 5. 原根与指标入…
Problem Description CRB has N different candies. He is going to eat K candies.He wonders how many combinations he can select.Can you answer his question for all K (0 ≤ K ≤ N )?CRB is too hungry to check all of your answers one by one, so he only asks…