A题:
A题题目链接
题目描述: Star TimeLimit: 1000ms MemoryLimit:32768KB64-bit integer IO format:%I64dProblem DescriptionOverpower often go to the playground with classmates. They play and chat on the playground. One day, there are a…
质因数分解
Miller Rabin 素性测试
根据费马小定理,我们能够得出一种检验素数的思路(即费马素性测试): 验证 ∀ 1 < a < n , a n − 1 ≡ 1 ( m o d n ) \forall 1 < a < n, a^{n - 1} \equiv 1(\mod n) ∀1<a&…
http://wenku.baidu.com/link?urlvKzZSSrCdYbfej5dfWZOFOzahSoQoO8SoC1RC7XCHVvDWZEhw7lFj76qzAx2hWDTMDfccbp4pBbZfOCNt57o-kVB1xD6z3vWVh9GCO-g01K (百度文库详解) 简单的总结一下: 一:数量积(点积,点乘,内积) a b ÿ…
A题:
A题题目链接
题目描述: The Water Problem TimeLimit:1000MS MemoryLimit:131072KB64-bit integer IO format:%I64dProblem DescriptionIn Land waterless, water is a very limited resource. People always fight for the biggest source of …
题目
Allen has an array a1,a2,…,an. For every positive integer k that is a divisor of n, Allen does the following: He partitions the array into n/k disjoint subarrays of length k. In other words, he partitions the array into the following subarrays: [a1,…
Codeforces Round 893 (Div. 2) 目录 A. Buttons题目大意思路核心代码 B. The Walkway题目大意思路核心代码 C. Yet Another Permutation Problem题目大意思路核心代码 A. Buttons 题目大意
一共有三个盒子分别是a、b、c,第一个人只能拿a、c,第二个人只…
文章目录 A. Rook题目题目大意思路核心代码 B. YetnotherrokenKeoard题目题目大意思路核心代码 C. Removal of Unattractive Pairs题目题目大意思路核心代码 D. Jumping Through Segments题目题目大意思路核心代码 E. Good Triples题目题目大意思路核心代码 F. Shift and Rever…
前言
数论大法好,人间真善美。。。 BSGS算法
一般用来求解成立的最小的L的解
对于求解这道题,要先进行分解
设 L i * x - y ,就得到 ,即
再移项 然后就是循环一遍 y 的值,将其存入HASH表中
在循环枚举 i &#…
题意:两只青蛙在同一纬度上(就是圆圈上)不同位置,具有不同的速度,看几次能跳的一起
解析:设经过t次调到一起,(xm*t)mod L(yn*t) mod L
上式整理一下 (xm*t)-(yn*t)p*L;(p是两只青…
You are given two arrays aa and bb of positive integers, with length nn and mmrespectively.
Let cc be an nmnm matrix, where ci,jai⋅bjci,jai⋅bj.
You need to find a subrectangle of the matrix cc such that the sum of its elements is at most xx, and its ar…
目录
A 简单的异或
题目:
解析:
B 这是dp题吗
题目链接:https://ac.nowcoder.com/acm/contest/63602/B
解析:
D 买饼干的小Y
题目:https://ac.nowcoder.com/acm/contest/63602/D
解析:
E 不爱吃早…
Problem DescriptionA given coefficient Kleads an intersection of two curves f(x)and gK(x). In the first quadrant, the curve fis a monotone increasing function that f(x)x−−√. The curve gis decreasing and g(x)K/x.To calculate the x-coordinate of the only …
Problem Problem 设奇数n>1n>1,证明:nn是素数的充分必要条件是n" role="presentation" style="position: relative;">nn不能表为三个或三个以上的连续正整数之和。 解: 必要性: 设自然数前缀…
目录 1 基础知识2 模板3 工程化 1 基础知识
中国剩余定理的内容如下:
已知整数 m 1 m_1 m1、 m 2 m_2 m2、… m k m_k mk两两互质,则对于任意的整数 a 1 a_1 a1、 a 2 a_2 a2… a k a_k ak,方程组 { x ≡ a 1 ( m o d m 1 ) x …
Problem Description Our lovely KK has a difficult mathematical problem:he has a N\left( 1\leq N\leq {10}^{18}\right)N(1≤N≤10 18 ) meters steel,he will cut it into steels as many as possible,and he doesn’t want any two of them be the same lengt…
#include <bitset>
#include <vector>
#include <iostream>
#include <algorithm>const int maxn 100000008;std::vector<int> prm, pre; // pre is the min-factor array.
bool np[maxn];void getPrime(const int N 100000000) {//线性筛&am…
蓝桥杯
我的AcWing
题目及图片来自蓝桥杯C AB组辅导课
数论(下) 蓝桥杯省赛中考的数论不是很多,这里讲几个蓝桥杯常考的知识点。 约数个数定理
我们如何去求一个数的约数个数呢? N N N分解质因数的结果: N P 1 α…
Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others) Total Submission(s): 6517 Accepted Submission(s): 1423 Problem Description 小Q非常喜欢数学,但是他的口算能力非常弱。因此他找到了小T,给了小T一个长…
比赛链接
AB都是思维,更确切地说,A考了字符串字典序,很经典的贪心考点,B考了MEX运算。C出的还是比较好的,dp方法值得学习。D题是个不太好想的容斥,主要是变量有点多,容易搞混。 A. Entertainme…
转自:杨美人! (a/b) mod ma mod (bm)/b
//求因子个数
int count(int n){int s1;for(int i2;i*i<n;i){if(n%i0){int a0;while(n%i0){n/i;a;}ss*(a1);}}if(n>1) ss*2;return s;
}
//求因子和
int sum(int n){int s1;for(int i2;i*i<n;i){if(n…
前置技能:
1.反素数,推荐博客:ACdreamers讲解反素数。定义:对于任何正整数 n ,其约数的个数记做 f(n) .例如 f(1) 1, f(6) 4 .如果某个正整数n满足:对于任意 i ( 0 < i < n ) ,都有 f( i ) < f( n ),则称 …
引
直线上的点
求直线 a x b y c 0 axbyc0 axbyc0上有多少个整点 ( x , y ) (x,y) (x,y)满足 x ∈ [ x 1 , x 2 ] , y ∈ [ y 1 , y 2 ] x\in[x1,x2],y\in[y1,y2] x∈[x1,x2],y∈[y1,y2]
扩展欧几里得算法
在解决引中的问题之前,我们需要学习一下扩展欧几里得…
蓝桥杯2023年第十四届省赛真题-公因数匹配
给定 n 个正整数 Ai,请找出两个数 i, j 使得 i < j 且 Ai 和 Aj 存在大于 1 的公因数。 如果存在多组 i, j,请输出 i 最小的那组。如果仍然存在多组 i, j,请输出 i 最小的所有方案中 j 最小的那…
文章目录 前言 洛谷P3455洛谷P1829洛谷P4449 前言
这里需要对莫反有一些基础。 不会的可以点这里
洛谷P3455
题意: 给定 a , b , d a,b,d a,b,d 求 ∑ x 1 a ∑ y 1 b [ gcd ( x , y ) d ] \sum_{x1}^a\sum_{y1}^b[\gcd(x,y)d] ∑x1a∑y1b[gcd(x,y)d…
2023-2024 ICPC, Swiss Subregional
C. Continued Fractions
题目链接 Continued Fractions
题意:
给定正整数 p p p,求使得 a b p \dfrac abp bap,且 a 1 b 1 , a 2 b 2 \dfrac{a1}{b1},\dfrac{a2}{b2} b1a1,b2a2 为整数的…
RXD is a good mathematician.One day he wants to calculate:∑i1nkμ2(i)⌊nki−−−√⌋output the answer module 1097.1≤n,k≤1018μ(n)1(n1)μ(n)(−1)k(np1p2…pk)μ(n)0(otherwise)p1,p2,p3…pkare different prime numbersInputThere are several test cases, please…
首先我们来看一道基础题: 题目链接:HDU1005 Number Sequence 题目描述: Number Sequence
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 147421 Accepted Submission(s): …
参考文献:
[CLOT21] Chillotti I, Ligier D, Orfila J B, et al. Improved programmable bootstrapping with larger precision and efficient arithmetic circuits for TFHE[C]//Advances in Cryptology–ASIACRYPT 2021: 27th International Conference on the T…
Codeforces Round 903 (Div. 3)ABCDE 目录 A. Dont Try to Count题目大意思路核心代码 B. Three Threadlets题目大意思路核心代码 C. Perfect Square题目大意思路核心代码 D. Divide and Equalize题目大意思路核心代码 E. Block Sequence题目大意思路核心代码 A. Don’t Try t…
退役OIer回来受虐啦
一些定义 μ ( x ) { 1 x > 1 ( − 1 ) n x ∏ i 1 n P i 0 o t h e r w i s e \mu(x) \begin{cases} 1 & x > 1 \\ (-1)^n & x \prod _ {i1} ^ {n} P_{i}\\ 0 & otherwise \end{cases} μ(x)⎩ ⎨ ⎧1(−1)n0x>1x∏i1nPi…
题目大意 题意来源 解题思路
首先我们假设存在 x x x满足 a , b ∈ [ l , r ] , g c d ( a , b ) x a,b\in[l,r],gcd(a,b)x a,b∈[l,r],gcd(a,b)x那么肯定 g c d ( ⌊ a / x ⌋ , ⌊ b / x ⌋ ) 1 就是互质 gcd(\lfloor a/x \rfloor, \lfloor b/x \rfloor)1就是互质 gcd(⌊a…
题目描述 分析
首先是扩展欧几里得算法的知识 然后是关于这个题的分析
代码
#include <bits/stdc.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b, ll &x, ll &y)
{if (!b){x 1, y 0;return a;}ll d gcd(b, a % b, y, x);y - a / b *…
完全剩余系
我们定义 a i ( 1 ≤ i ≤ n ) a_i(1\le i\le n) ai(1≤i≤n) 为模 m m m 的完全剩余系当且仅当对于 1 ≤ i , j ≤ n 1\le i,j\le n 1≤i,j≤n 且 i ≠ j i\ne j ij,满足 a i ≢ a j ( m o d m ) a_i\not\equiv a_j\pmod m ai≡aj(mo…
// 素数表 N
static int visited[N];memset(visited, 0, sizeof(visited));int m sqrt(N 0.5);for(int i 2; i < m; i)if(!visited[i])for(int j i*i; j < N; j i)visited[j] 1;
// 快速幂 -> a^b
LL quick_pow(LL a, LL b)
{LL ret 1;LL temp a;while(b)…
const int maxn50;
//有equ个方程,var个变元。增广矩阵行数为equ,列数为var1
int equ,var;
int a[maxn][maxn]; //增广矩阵
int x[maxn]; //解集
int free_x[maxn];
int free_num;
void init(){memset(a,0,sizeof(a));memset(x,0,sizeof(x));equ30,var3…