
数论
文章平均质量分 61
Allen-h
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
三角形
链接:https://ac.nowcoder.com/acm/contest/75/I 来源:牛客网 题目描述 给你一个三角形的顶点A,B,C的坐标(坐标都为整数),请求出三角形的面积,三角形内的点的个数以及边AB、BC和AC边上的点的个数(不包括顶点ABC) 输入描述: 多组输入 每组输入三行,每行两个整数 第一行顶点A的坐标Xa,Ya. 第二行顶点B的坐标Xb,Yb. 第三...原创 2018-11-15 20:19:56 · 341 阅读 · 0 评论 -
1041: [HAOI2008]圆上的整点
题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1041 题目大意:求一个给定的圆(x^2+y^2=r^2),在圆周上有多少个点的坐标是整数。 题解: ∵ x^2+y^2=r^2∴ x^2=r^2-y^2∴x^2=(r-y)(r+y) 设d=gcd(r-y,r+y); r-y=d*a^2; r+y=d*b^2; (a&l...原创 2019-09-04 21:05:33 · 286 阅读 · 0 评论 -
HDU - TrickGCD
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6053 题目大意:给一个长度为n的数组,构造出一个长度为n的数组满足1≤Bi≤Ai,且任意区间gcd>=2; 思路:对于每一个gcd都有a[i]/gcd个然后把每个值乘起来,对于所有序列的重复性恰好为莫比乌斯函数的规律。(莫比乌斯函数+容斥+筛法) #include <bits/st...原创 2019-05-12 18:19:00 · 248 阅读 · 0 评论 -
积性函数与线性筛
常见积性函数: μ(n):莫比乌斯函数 φ(n):欧拉函数 d(n):一个数nn的约数个数 σ(n):一个数nn的约数和 f(x)=xk(k∈N):这个玩意儿也是积性函数 线性筛素数: int pri[N],tot,isprime[N];//isprime[i]为1的表示不是质数 void sieve() { isprime[1]=1; for (int i=2;i<...原创 2019-05-15 15:37:33 · 247 阅读 · 0 评论 -
Farey Sequence
题目链接:https://vjudge.net/problem/POJ-2478 The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arranged i...原创 2018-11-26 19:12:40 · 473 阅读 · 0 评论 -
2017ccpc杭州(数论)
题目链接:https://vjudge.net/contest/268674#problem/B 题意: 依次输入一个整数分解质因数的各项底数与指数,求算: ∑d|nφ(d)×n/d 思路:迪利克雷卷积知识和欧拉函数的知识 可以看出它是个积性函数 推导如下图: 代码: #include <bits/stdc++.h> using namespace std;...原创 2018-11-26 17:29:29 · 426 阅读 · 0 评论 -
“东信杯”广西大学第一届程序设计竞赛(同步赛)
链接:https://ac.nowcoder.com/acm/contest/283/B 来源:牛客网 不吉利的数 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 131072K,其他语言262144K 64bit IO Format: %lld 题目描述 在数学中,某个序列的子序列是从最初序列通过去除某些元素但不破坏余下元素的相对位置(在前或在后)而形成的新序列。 ...原创 2018-11-25 18:54:23 · 1969 阅读 · 2 评论 -
Pairs Forming LCM LightOJ - 1236
题目链接:https://cn.vjudge.net/problem/LightOJ-1236 Find the result of the following code: long long pairsFormLCM( int n ) { long long res = 0; for( int i = 1; i <= n; i++ ) for( int ...原创 2018-11-20 20:42:55 · 369 阅读 · 0 评论 -
Help Hanzo LightOJ - 1197
题目链接:https://cn.vjudge.net/problem/LightOJ-1197 Amakusa, the evil spiritual leader has captured the beautiful princess Nakururu. The reason behind this is he had a little problem with Hanzo Hattori, ...原创 2018-11-20 20:27:24 · 295 阅读 · 0 评论 -
Trailing Zeroes (III) LightOJ - 1138
题目链接:https://cn.vjudge.net/problem/LightOJ-1138 You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know N! = 1*2*...*N. For ex...原创 2018-11-20 20:17:11 · 434 阅读 · 0 评论 -
GCD - Extreme (II) UVA - 11426
题目链接:https://cn.vjudge.net/problem/UVA-11426 题意:跟你一个n让你求(1,2....n-1)分别到n的所有gcd之和。 思路:欧拉函数的运用。我们用b[n]表示(1....n-1)与ngcd之和。得到递推式sum[n]=sum[n-1]+b[n]; 设a[i]表示gcd(n,(1到n-1))=i;我们知道gcd(n/i,(1到n-1)/i)=1;我...原创 2018-11-20 20:13:53 · 262 阅读 · 0 评论 -
扩展欧几里德
定理一:如果d = gcd(a, b),则必能找到正的或负的整数k和l,使d = a*x+ b*y。 定理二:若gcd(a, b) = 1,则方程ax ≡ c (mod b)在[0, b-1]上有唯一解。 定理三:若gcd(a, b) = d,则方程ax ≡ c (mod b)在[0, b/d - 1]上有唯一解。 证明:上述同余方程等价于ax + by = c,如果有解,两边同除以d,就有a/d...原创 2018-07-18 10:48:29 · 269 阅读 · 0 评论 -
牛客网-数的变换
链接:https://ac.nowcoder.com/acm/contest/52/C 题目描述 给定一个序列数列 , (ai互不相同) 3种映射关系 现在对于给定询问(x, k),求 输入描述: 多组读入数据T, 对于每组数据, 第1行一个整数n,q,n表示数列的大小,q为询问数 第2行读入n个数a1,a2,…,an,表示数列中的数 接下来q行,每行读入2个整...原创 2018-11-08 19:07:47 · 499 阅读 · 0 评论 -
Aladdin and the Flying Carpet(LightOJ - 1341)
It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a powerful Genie. Here we are concerned about the first mystery. Aladdin was about to enter to a magi...原创 2018-11-08 19:18:34 · 226 阅读 · 0 评论 -
Leading and Trailing(LightOJ - 1282)
You are given two integers: n and k, your task is to find the most significant three digits, and least significant three digits of nk. Input Input starts with an integer T (≤ 1000), denoting the num...原创 2018-11-08 19:28:38 · 207 阅读 · 0 评论 -
Harmonic Number(LightOJ - 1234)
In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers: In this problem, you are given n, you have to find Hn. Input Input starts with an integer T...原创 2018-11-08 19:31:44 · 226 阅读 · 0 评论 -
1951: [Sdoi2010]古代猪文
题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1951 题目大意:计算G^∑i|nC(n,i)%P 题解:数论+中国剩余定理+费马小定理+逆元+lucas定理。 根据 费马小定理a^(p-1)≡1(mod p) 设∑i|nC(n,i)=M; 设M=k*(p-1)+W: 则G^∑i|nC(n,i)=G^M=G^(k*(p-1)...原创 2019-09-05 21:02:37 · 273 阅读 · 0 评论