随笔分类 -  算法-数论 / 数论

摘要:链接:https://ac.nowcoder.com/acm/contest/73202/B 来源:牛客网 问题描述 有三种数量无限的砝码和一个天平,天平的一端有一个质量为m的物品,问能否通过放置砝码使得天平平衡? 输入描述: 第一行包含一个整数 \(T \ (1 \leq T \leq 1 阅读全文
posted @ 2024-01-17 16:33 lipu123 编辑
摘要:// 求x, y,使得ax + by = gcd(a, b) int exgcd(int a, int b, int &x, int &y) { if (!b) { x = 1; y = 0; return a; } int d = exgcd(b, a % b, y, x); y -= (a/b) 阅读全文
posted @ 2023-12-22 21:09 lipu123 编辑
摘要:https://leetcode.cn/problems/count-subarrays-where-max-element-appears-at-least-k-times/description/ 给你一个整数数组 nums 和一个 正整数 k 。 请你统计有多少满足「nums 中的最大元素」至 阅读全文
posted @ 2023-12-13 17:38 lipu123 编辑
摘要:这个需要素数筛 #include<iostream> #include<algorithm> using namespace std; const int maxn=4e5+100; int prime[maxn]; int biaoji[maxn]; int cnt; void getPrime( 阅读全文
posted @ 2023-10-22 10:36 lipu123 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/11216/G来源:牛客网 痛定思痛,奋楫争先再出发…… q 次询问。每次询问给定 n 和 K,问 1 ~ n 中有多少数可以表示为大于等于 K 的质数的乘积(一个数可以乘多次)。 输入描述: 链接:https://ac. 阅读全文
posted @ 2021-11-14 23:38 lipu123 阅读(86) 评论(0) 推荐(0) 编辑
摘要:题目链接 链接:https://ac.nowcoder.com/acm/contest/11216/G来源:牛客网 痛定思痛,奋楫争先再出发…… q 次询问。每次询问给定 n 和 K,问 1 ~ n 中有多少数可以表示为大于等于 K 的质数的乘积(一个数可以乘多次) 题解 可以发现,如果一个数的最小 阅读全文
posted @ 2021-11-11 23:57 lipu123 阅读(86) 评论(0) 推荐(0) 编辑
摘要:传送门 小y有n个数字(1n),他每次会在里面等概率随机选取两个数x,y(两个数互不影响),求x的概率(对23333取模) 保证n23333取模的结果:假设答案化为最简分式后的形式为a/b, 其中ab互质。 输出整数 x 使得 阅读全文
posted @ 2021-11-09 21:13 lipu123 阅读(66) 评论(0) 推荐(0) 编辑
摘要:The Euler function, φ, is known to be important in math theory. Given a positive integer n, φ(n) is defined as the number of integers in [1,n] that ar 阅读全文
posted @ 2021-09-28 00:59 lipu123 阅读(42) 评论(0) 推荐(0) 编辑
摘要:题目描述: 传送门 如果不知道三分的可以看看这个传送门 令g(x)x中各位数和,例如g(123456)=1+2+3+4+5+6,然后有T次询问,每次询问给你一个a,b,c,d,n 让你求$f(x)=Ax^{2}g(x)+Bx^{2}+Cxg^{2}(x)+Dxg(x 阅读全文
posted @ 2021-08-29 19:31 lipu123 阅读(40) 评论(0) 推荐(0) 编辑
摘要:题目 题目链接 You are given an array aa of length nn. You are asked to process qq queries of the following format: given integers i and x, multiply ai by x. 阅读全文
posted @ 2021-08-04 21:34 lipu123 阅读(52) 评论(0) 推荐(0) 编辑
摘要:Among the strings of length A+B containing A occurrences of a and B occurrences of b, find the string that comes K-th in the lexicographical order.Con 阅读全文
posted @ 2021-07-24 12:17 lipu123 阅读(134) 评论(0) 推荐(0) 编辑
摘要:在遥远的公元前65536世纪,β星座的焃碁星人发现了地球,他们对于该星球上碳基生物的大脑构造感到非常的好奇, 在植入了夸克级别的神经元控制器后, 他们夺取了所有生物大脑内惊人的算力,进而控制了所有的生物。几亿年以后, 人类凭借着自己贫瘠的算力, 造出了庞大而惊人的超大规模集成电路,他们训练的Alph 阅读全文
posted @ 2021-07-22 11:34 lipu123 阅读(186) 评论(0) 推荐(0) 编辑
摘要:1862. 向下取整数对和 给你一个整数数组 nums ,请你返回所有下标对 0 <= i, j < nums.length 的 floor(nums[i] / nums[j]) 结果之和。由于答案可能会很大,请你返回答案对109 + 7 取余 的结果。 函数 floor() 返回输入数字的整数部分 阅读全文
posted @ 2021-06-19 18:23 lipu123 阅读(199) 评论(0) 推荐(0) 编辑
摘要:题目链接 给你一个二进制串 s (一个只包含 0 和 1 的字符串),我们可以将 s 分割成 3 个 非空 字符串 s1, s2, s3 (s1 + s2 + s3 = s)。 请你返回分割 s 的方案数,满足 s1,s2 和 s3 中字符 '1' 的数目相同。 由于答案可能很大,请将它对 10^9 阅读全文
posted @ 2021-06-18 00:10 lipu123 阅读(111) 评论(0) 推荐(0) 编辑
摘要:传送门 D. Another Problem About Dividing Numbers You are given two integers a and b. In one turn, you can do one of the following operations: Take an int 阅读全文
posted @ 2021-06-13 00:46 lipu123 阅读(213) 评论(0) 推荐(0) 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/11173/E来源:牛客网 小 L 作为一位 oier 在 NOIP2017 考场上看着“小凯的疑惑”产生了疑惑。 小 L 手中有两种面值的金币,两种面值均为正整数且彼此互素。每种金币小 L都有无数个。 在不找零的情况下, 阅读全文
posted @ 2021-05-26 21:23 lipu123 阅读(179) 评论(0) 推荐(0) 编辑
摘要:The world famous pirate Cornelius “Cheesehead” Bakker was a renowned astronomer and mathematician. He buried most of his treasury in the Caribbean isl 阅读全文
posted @ 2021-05-04 20:18 lipu123 阅读(102) 评论(0) 推荐(0) 编辑
摘要:传送门 这个题的题意就是 给出n个数,可以自己求出他们的最大公因数m,去掉最少的数使得剩下的数的最大公因数大于m,如果没有解决方案则输出 -1即可 这个题你先求出来它的m,然后令每一个数除以m,这样就转化成了求剩下数的gcd为i这个值的最多保留多少个,这样用埃式筛筛一下就行 为什么要这样呢,因为你都 阅读全文
posted @ 2021-05-03 19:46 lipu123 阅读(60) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示