随笔分类 - 数论
摘要:题意:求两个手环任意旋转对应位置的差值+c的平方最小 设b旋转到k最小,那么先将b扩张一倍构成一圈,那么答案式子就是 将这个式子展开一下,事情就变得有趣了起来 这个式子将a[ ]翻转可以化成卷积形式 直接套上一个FFT就可以了 然后枚举C就行了(C的范围比较小,主要是写起来容易,追求效率可以用求根公
阅读全文
摘要:有n个小朋友,m颗糖,你要把所有糖果分给这些小朋友。规则第 i 个小朋友没有糖果,那么他之后的小朋友都没有糖果。、如果一个小朋友分到了 xx 个糖果,那么的他的权值是 f(x) = ox^2 + sx + u没有分到糖果的小朋友的权值是 1 每种方案的权值是各个小朋友权值的乘积求出所有方案的权值和
阅读全文
摘要:题意显然 ans=回文子序列数目 - 回文子串数目 回文子串直接用马拉车跑出来 回文子序列一开始总是不知道怎么求 (太蠢了) 后面看了题解 构造一个神奇的卷积 (这个是我盗的图)地址 后面还有一些细节需要处理出 f[x] (f[x] 表示 x左右相等的个数) 通常我们需要的情况是 两个函数相乘 这里
阅读全文
摘要:题目描述 给定一个长度为N的数组A[],求有多少对i, j, k(1<=i<j<k<=N)满足A[k]-A[j]=A[j]-A[i]。 输入格式 第一行一个整数N(N<=10^5)。接下来一行N个数A[i](A[i]<=30000)。 输出格式 一行一个整数。 样例输入 样例输出
阅读全文
摘要:题目描述 我们讲一个悲伤的故事。 从前有一个贫穷的樵夫在河边砍柴。 这时候河里出现了一个水神,夺过了他的斧头,说: “这把斧头,是不是你的?” 樵夫一看:“是啊是啊!” 水神把斧头扔在一边,又拿起一个东西问: “这把斧头,是不是你的?” 樵夫看不清楚,但又怕真的是自己的斧头,只好又答:“是啊是啊!”
阅读全文
摘要:N wizards are attending a meeting. Everyone has his own magic wand. N magic wands was put in a line, numbered from 1 to n(Wand_i owned by wizard_i). A
阅读全文
摘要:Yinyangshi is a famous RPG game on mobile phones. Kim enjoys collecting cards in this game. Suppose there are n kinds of cards. If you want to get a n
阅读全文
摘要:E. Border time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Astronaut Natasha arrived on Ma
阅读全文
摘要:C. Line time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A line on the plane is described
阅读全文
摘要:链接:https://www.nowcoder.com/acm/contest/114/B来源:牛客网 题目描述 Ans = 0; For(inti = 1; i <= n; i++) For(int v = 0; v <= n; v++) Ans = (Ans + C(i, v) * C(i, v
阅读全文
摘要:Description Alice and Bob are in their class doing drills on multiplication and division. They quickly get bored and instead decide to play a game the
阅读全文
摘要:链接:https://www.nowcoder.com/acm/contest/113/B来源:牛客网 题目描述 给长度为n的序列A,长度为m的序列B。可以给A序列里每个元素加上x且B序列里每个元素减去x (x可以是负数),问的最小值 输入描述: 第一行两个整数分别表示n,m接下来一行n个整数表示序
阅读全文
摘要:链接:https://www.nowcoder.com/acm/contest/113/A来源:牛客网 题目描述 给出四堆石子,石子数分别为a,b,c,d。规定每次只能从堆顶取走石子,问取走所有石子的方案数。 输入描述: 在一行内读入四个由空格分隔的整数a,b,c,d, 输入均为不超过500的正整数
阅读全文
摘要:C. Three Garlands time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output C. Three Garlands time
阅读全文
摘要:C. Finite or not? time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given several q
阅读全文
摘要:链接:https://www.nowcoder.com/acm/contest/109/C来源:牛客网 题目描述 给定长度为n的数组a,定义一次操作为: 1. 算出长度为n的数组s,使得si= (a[1] + a[2] + ... + a[i]) mod 1,000,000,007; 2. 执行a
阅读全文
摘要:链接:https://www.nowcoder.com/acm/contest/105/G来源:牛客网 题目描述 这是一个加强版的斐波那契数列。 给定递推式 求F(n)的值,由于这个值可能太大,请对109+7取模。 输入描述: 第一行是一个整数T(1 ≤ T ≤ 1000),表示样例的个数。以后每个
阅读全文
摘要:Description Saruman’s army of orcs and other dark minions continuously mine and harvest lumber out of the land surrounding his mighty tower for N cont
阅读全文
摘要:Description Everybody loves big numbers (if you do not, you might want to stop reading at this point). There are many ways of constructing really big
阅读全文
摘要:链接:https://www.nowcoder.com/acm/contest/93/K来源:牛客网 题目描述 wyh学长特别喜欢斐波那契数列,F(0)=0,F(1)=1,F(n)=F(n-1)+F(n-2)(n>=2) 一天他突发奇想,想求F(a^b)%c 输入描述: 输入第一行一个整数T(1<=
阅读全文

浙公网安备 33010602011771号