![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数论与数学
数论与数学
ZzzzGgggHhhh
这个作者很懒,什么都没留下…
展开
-
Wannafly挑战赛5——D
子序列从m个位置中选出n个位置,每个位置有26种选择,这样就会出现重复的情况,例如题中的样例,按照这种方法,答案就是52。a_ _ b_ _ c_ _ _ ,a与b之间不能为a,b与c之间不能为b,所以,前面的空有25种选择方式,后面的空有26种选择方式,所以,只需要枚举字符串最后一位的位置,答案为C(i-1,n-1)*25(i-n)*26(m-i)相加的和。#include<bits/stdc++.h>using namespace std;typedef long long ll原创 2020-12-08 16:03:01 · 98 阅读 · 0 评论 -
洛谷——P6298 齿轮
题目描述Daniel13265 从不知哪里找来了 nn 个齿轮,第 ii 个齿轮的齿数为不超过 mm 的正整数 a_iai 。他现在想把其中 kk 个齿轮按照一定的方式拼接在一起。当齿轮使用一段时间后,就会产生损耗。一个齿轮组的损耗速率是由这个齿轮组的所有齿轮齿数的最大公约数决定的:最大公约数越大,相同的齿之间啮合的频率就会增高,从而损耗的速率就会变快。这个最大公约数又被称为损耗因子。算出一个齿轮组的损耗因子是很容易的。可是现在 Daniel13265 想要知道,对于可能拼接出的所有齿轮组的损原创 2020-10-10 16:23:51 · 148 阅读 · 0 评论 -
牛客练习赛71——C.数学考试
时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述牛牛在树剖姐姐的数学考试里出了一个题,但是树剖姐姐不会做,于是她向您求助。求 1\sim n1∼n 的排列,有 m 个限制条件,第i个限制条件 p_ipi 表示前 p_ipi 个数不能是 1\sim p_i1∼pi 的排列,求符合要求的排列的个数。答案对 20000311 取模。输入描述:第一行两个 n,m第二行 m原创 2020-10-10 09:51:28 · 338 阅读 · 0 评论 -
快速傅里叶变换(FFT)
洛谷模板题大佬博客1大佬博客2留个板子,供以后用#include<iostream>#include<cmath>#include<cstdio>#include<cstring>using namespace std;typedef long long ll;const int N=4e6+500;const double PI=acos(-1.0);int n,m,limit=1,l,r[N];struct complex {原创 2020-09-28 20:49:13 · 149 阅读 · 0 评论 -
2020牛客暑期多校训练营(第九场)——E
Groundhog Chasing Death链接:https://ac.nowcoder.com/acm/contest/5674/E来源:牛客网时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述As we all know,“Groundhog chasing death” means “GCD”,while “GCD” stands for “greatest common divisor原创 2020-09-08 21:26:38 · 156 阅读 · 0 评论 -
CF——501D(变进制数康托展开)
D. Misha and Permutations Summationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet’s define the sum of two permutations p and q of numbers 0, 1, …, (n - 1) as permutation , where Perm(x) is the原创 2020-08-23 18:20:17 · 133 阅读 · 0 评论 -
牛客——等级之题 N1(8.3)
链接:https://ac.nowcoder.com/acm/contest/6766/A来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述有一个箱子,开始时有n个黑球,m个蓝球。每一轮游戏规则如下:第一步:奕奕有p的概率往箱子里添加一个黑球,有(1-p)的概率往箱子里添加一个蓝球。第二步:华华随机从箱子里取出一个球。华华喜欢黑球,他想知道k轮游戏之后箱子里黑球个数的期望。输原创 2020-08-05 22:39:09 · 307 阅读 · 0 评论 -
整除分块板子
#include<bits/stdc++.h>using namespace std;typedef long long ll;const ll mod=1e9+7;ll zcfk(ll n,ll k) { if(k>=n) { ll cut=0; for(ll l=2,r; l<=n; l=r+1) { r=n/(n/l); cut=(cut+1ll*(r-l+1)*(n/l)%mod)%mod; } return cut; } else {原创 2020-08-01 15:28:29 · 139 阅读 · 0 评论 -
2020牛客暑期多校训练营(第四场)——H
Harder Gcd Problem时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288KSpecial Judge, 64bit IO Format: %lld题目描述After solving the Basic Gcd Problem, ZYB gives you a more difficult one:Given an integer n{n}n, find two subset A{A}A and B{B}B of {1,2,…,n}{1原创 2020-07-20 23:34:06 · 202 阅读 · 0 评论 -
2020牛客暑期多校训练营(第三场)——F
Fraction Construction Problem题目描述There are t queries.In each query, you are given two positive integers a and b (a, b \le 2 \times 10^6a,b≤2×106).Please print a line consists of four positive integers c,d,e,f satisfying the following constraints:• \fr原创 2020-07-19 22:13:47 · 649 阅读 · 0 评论 -
EOJ Monthly 2020.7 Sponsored by TuSimple——E
因数串很少能遇到这种用到基础数论知识的题,写篇博客复习一下。首先,输入的n对数,是将这个数进行质因数分解的结果,任何一个大于1的正整数都能唯一分解为有限个质数的乘积,可写作:N=p1c1p2c2p3c3…pmcm其中pi都是质数,其p1<p2<p3…<pm。一个数的因子个数为:(c1+1)(c2+1)(c3+1)…*(cm+1)#include<bits/stdc++.h>using namespace std;typedef long long ll;ll原创 2020-07-17 23:56:14 · 387 阅读 · 0 评论 -
2020牛客暑期多校训练营(第二场)——K
Keyboard Free链接:https://ac.nowcoder.com/acm/contest/5667/K来源:牛客网时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Given three concentric circles whose radiuses are r_1, r_2, r_3r1,r2,r3 respectively, and {A,B,C}A,B,C are原创 2020-07-17 16:29:20 · 273 阅读 · 0 评论 -
Atcoder-AIsing Programming Contest 2020-D
Anything Goes to Zero题意:给定一个二进制串,按位计算,计算每一位时,取反,得到一个二进制数,用其取余其二进制下1的个数,得到结果,再执行同样的取余步骤,直到结果为0,输出所需的步数。做法:每一位取反,在二进制下1的个数,就是整体串中1的个数加一或减一,先预处理出不取反时的结果,然后每一位判断,加上或减去该位的变化,计算结果即可。简单来说就是:先这样,再这样,然后这样,最后输出就好了。切记快速幂时,数据类型定义为longlong,不然就会乘炸了(因题而定)。比赛时没开long原创 2020-07-12 22:26:44 · 180 阅读 · 0 评论 -
2019南昌邀请赛-F
F - SequenceOldjang has a sequence A of length n , the i t h number in which is A i . He defined a function f ( l , r ) = a l ⊕ a l + 1 ⊕ ⋯ ⊕ a r . It is simple for the cleverest boy oldjang to calculate the function, so he wants to make the problem more原创 2020-07-08 18:01:36 · 140 阅读 · 0 评论 -
牛客联系赛62-B
在 t 秒内,走 x 次向上的,走 y 次向右的,所以答案是组合数学。#include<stdio.h>#include<algorithm>using namespace std;typedef long long ll;const ll mod=998244353;const int N=1e5;ll jc[N],inv[N];ll quick_mod...原创 2020-04-29 16:50:01 · 175 阅读 · 0 评论 -
牛客练习赛60-D
比赛的时候没有做出来,今天补题的时候看了大佬的代码,也不至于太难理解,但当时就是没想出来,只能说大佬牛逼。K取余C,余下的部分用A和B补。先预处理出X个A取余C的所以情况,每种情况各需要几个A,B同样预处理出来,然后让X个A和Y个B取余C的余数凑出K取余C的余数即可。#include<bits/stdc++.h>using namespace std;typedef long ...原创 2020-03-28 11:55:51 · 166 阅读 · 0 评论 -
Codeforces-1323D
D. PresentCatherine received an array of integers as a gift for March 8. Eventually she grew bored with it, and she started calculated various useless characteristics for it. She succeeded to do it f...原创 2020-03-09 19:38:35 · 263 阅读 · 0 评论 -
HDU 5984
Pocky HDU - 5984Let’s talking about something of eating a pocky. Here is a Decorer Pocky, with colorful decorative stripes in the coating, of length L.While the length of remaining pocky is longer t...原创 2020-02-05 14:24:28 · 160 阅读 · 0 评论 -
CodeForces - 1284C
New Year and PermutationRecall that the permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permu...原创 2020-01-05 11:21:42 · 237 阅读 · 0 评论 -
CodeForces - 1279D
D. Santa’s BotSanta Claus has received letters from n different kids throughout this year. Of course, each kid wants to get some presents from Santa: in particular, the i-th kid asked Santa to give t...原创 2019-12-28 15:46:13 · 203 阅读 · 0 评论 -
P1582 倒水(洛谷)
只要求出的n转为二进制下,有k个1即可。lowbit(n)取出非负整数n在二进制表示下最低位的1以及它后边的0构成的数值。__builtin_popcountll(n)求出非负整数n在二进制表示下有几个1。让n一直加lowbit(n),进位减少二进制表示下1的个数。#include<stdio.h>#include<algorithm>using namesp...原创 2019-12-23 17:19:03 · 174 阅读 · 0 评论 -
牛客小白月赛17-J(组合数学)
题目链接:https://ac.nowcoder.com/acm/contest/1085/J题目描述小sun最近对计数问题来了兴趣,现在他有一个问题想问问你:有一个含有n个数字的序列,每个数的大小是不超过1000的正整数,同时这个序列是个单调不增序列。但是很不幸的是,序列在保存过程中有些数字丢失了,请你根据上述条件,计算出有多少种不同的序列满足上述条件,答案对1000000007取模。(具...原创 2019-12-02 17:19:32 · 204 阅读 · 0 评论 -
NUC-家喻户晓的中药店
问题描述long_xiao和const_hhh是一对恩爱的夫妻。他们在京城经营着一家中药店,夫妻二人医术精湛、古道热肠,虽然年过花甲,身体依然硬朗。更重要的是,他们的思维仍然十分活跃,不仅了解大家的要求,还能给他们许多惊喜。除了治病救人,他们的中药配方还有舒筋活络,排毒养颜的功效。正因为如此,中药店门庭若市,甚至有人不远千里,慕名而来。药店里药材种类繁多,组成的配方也就非常多。为了提高服务...原创 2019-11-30 19:05:25 · 138 阅读 · 0 评论 -
CodeForces - 1263C(整除分块)
C. Everyone is a Winner!On the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following algorithm: if k participants take ...原创 2019-11-30 10:38:41 · 271 阅读 · 0 评论 -
CodeForces - 785D(组合数学)
As you probably know, Anton goes to school. One of the school subjects that Anton studies is Bracketology. On the Bracketology lessons students usually learn different sequences that consist of round ...原创 2019-11-12 19:28:40 · 138 阅读 · 0 评论 -
HDU - 6265
Master of Phi本题运用数论知识:积性函数+欧拉函数+狄利克雷卷积积性函数:欧拉函数:欧拉函数:上式可转化为:该题可求解下式的解:根据积性函数特性可将上式转化为:将欧拉函数带入可化简为下式:所以答案为:代码如下#include<stdio.h>#include<algorithm>using namespace std;...原创 2019-10-30 17:39:08 · 130 阅读 · 0 评论