![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数论
许嵩前男友
这个作者很懒,什么都没留下…
展开
-
洛谷P2431正妹吃月饼
刷题之路-数论洛谷P2431正妹吃月饼传送门题目描述做题思路将a转换成二进制,然后从最小位开始,对每一位进行判断:若为0,则转换为1,若转换后大于b,则结束,否则继续。最后对a中的1的个数进行统计代码#include<iostream>#include<algorithm>#include<cstring>#include<queue>#include<cmath>using namespace std;const in原创 2021-03-07 10:28:01 · 103 阅读 · 0 评论 -
洛谷P1088火星人
刷题之路-数论洛谷P1754球迷购票问题传送门题目可以理解为构造一个元素为-1和1的数组,使得数组任意前缀不小于0可以转换到平面坐标系中从(0, 0)点出发到(n, n)点的路径数,且过程中x >= y#include<iostream>#include<map>#include<set>#include<vector>#include<algorithm>#include<cstring>#include原创 2021-02-24 15:58:31 · 66 阅读 · 0 评论 -
洛谷P1630求和
刷题之路-数论洛谷P1630求和传送门核心:(a + b) ^ x ≡ a ^ x (% b)因此 1 ^ b ≡ (1 + mod) ^ b (% mod)#include<iostream>#include<map>#include<set>#include<vector>#include<algorithm>#include<cstring>#include<string>#include&原创 2021-02-24 15:00:55 · 136 阅读 · 0 评论 -
洛谷P1338末日的传说
数论洛谷P1154奶牛分厩传送门若a ≡ b ( % c),则a = kc + b,k∈Z。当K为两只奶牛的标号之差时,两只奶牛的牛厩相同,所以找到最小的并且不是任意两个标号之差的值,并且要大于奶牛的数量const int N = 5005;const int M = 1000005;int a[N], b[M];int main(){ int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i];原创 2021-02-23 15:35:24 · 68 阅读 · 0 评论 -
洛谷P2789直线交点
刷题之路-数论洛谷P2789直线交点传送门题目描述n条直线,当其中有r条平行时,有两类交点:r条平行线与其它直线的交点,以及剩下的(n - r)条直线的交点。因为题目要求无三线共点,所以第一类的交点个数可以直接求,个数为r * (n - r)。第二类的交点,可以递归求,因为它可以视为(n - r)条直线求交点。因此,用一个数组标记出现过的交点数,最后进行统计。#include<iostream>#include<map>#include<set>#in原创 2021-03-05 10:48:39 · 248 阅读 · 1 评论 -
洛谷P3414组合数
刷题之路-数论洛谷P3414组合数传送门(x + y) ^ n当 x = 1 && y = 1时可得当 x = 1 && y = -1时可得因此,原题可转换成求 2 ^ (n - 1)#include<iostream>#include<cstdio>using namespace std;const int mod = 6662333;typedef long long ll;ll qmi(ll a, ll b){转载 2021-03-01 20:14:37 · 62 阅读 · 0 评论