![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ACM_数学 TDMTDMTDMTDM
文章平均质量分 50
tomjobs
别慌,慌也没用
展开
-
LeetCode 1739. 放置盒子(推公式)
思路:最终一定是按照下面这样排列,方格上的数字代表这个位置可以垒多高。图1图2所以假设底面放的数目为midmidmid:先按照(N+1)∗N/2=mid(N+1)*N/2=mid(N+1)∗N/2=mid算出N,也就是图一中的梯形图的高度。那么结果就是∑i=1N(i+1)∗i2\sum_{i=1}^N\frac{(i+1)*i}{2}∑i=1N2(i+1)∗i。还剩下一部分是num2=mid−(N+1)∗N/2num2=mid-(N+1)*N/2num2=mid−(N+1)∗N/2,.原创 2021-02-02 22:38:13 · 2529 阅读 · 2 评论 -
Codeforces 1459 Row GCD(GCD,结论)
You are given two positive integer sequences ????1,…,???????? and ????1,…,????????. For each ????=1,…,???? find the greatest common divisor of ????1+????????,…,????????+????????.InputThe first line contains two integers ???? and ???? (1≤????,????≤2⋅105).原创 2020-12-20 17:19:35 · 425 阅读 · 0 评论 -
洛谷P1145 约瑟夫
题目描述nn个人站成一圈,从某个人开始数数,每次数到mm的人就被杀掉,然后下一个人重新开始数,直到最后只剩一个人。现在有一圈人,kk个好人站在一起,kk个坏人站在一起。从第一个好人开始数数。你要确定一个最小的mm,使得在第一个好人被杀死前,kk个坏人先被杀死。感谢yh大神指出样例数据的错误。输入格式一个k(0<k<14)k(0<k<14)输出格式一个mm输入输...原创 2019-11-15 22:19:01 · 977 阅读 · 0 评论 -
P2737 [USACO4.1]麦香牛块Beef McNuggets(最大不能表示数,结论题)
题目描述农夫布朗的奶牛们正在进行斗争,因为它们听说麦当劳正在考虑引进一种新产品:麦香牛块。奶牛们正在想尽一切办法让这种可怕的设想泡汤。奶牛们进行斗争的策略之一是“劣质的包装”。“看,”奶牛们说,“如果你只用一次能装3块、6块或者10块的三种包装盒包装麦香牛块,你就不可能满足一次只想买1、2、4、5、7、8、11、14或者17块麦香牛块的顾客了。劣质的包装意味着劣质的产品。”你的任务是帮助这些奶...原创 2019-09-01 11:03:17 · 200 阅读 · 0 评论 -
P2735 电网 Electric Fences 题解(皮克定律)
展开题目描述在本题中,格点是指横纵坐标皆为整数的点。为了圈养他的牛,农夫约翰(Farmer John)建造了一个三角形的电网。他从原点(0,0)牵出一根通电的电线,连接格点(n,m)(0<=n<32000,0<m<32000),再连接格点(p,0)(p>0),最后回到原点。牛可以在不碰到电网的情况下被放到电网内部的每一个格点上(十分瘦的牛)。如果一个格点碰到了...原创 2019-09-01 17:40:12 · 252 阅读 · 0 评论 -
P2723 丑数 Humble Numbers(数学)
题目背景对于一给定的素数集合 S = {p1, p2, …, pK},考虑一个正整数集合,该集合中任一元素的质因数全部属于S。这个正整数集合包括,p1、p1p2、p1p1、p1p2p3…(还有其它)。该集合被称为S集合的“丑数集合”。注意:我们认为1不是一个丑数。题目描述你的工作是对于输入的集合S去寻找“丑数集合”中的第N个“丑数”。所有答案可以用longint(32位整数)存储。补充:丑...原创 2019-09-02 22:31:50 · 388 阅读 · 0 评论 -
Constructing Tests CodeForces - 938C(数学,枚举乘积)
Let’s denote a m-free matrix as a binary (that is, consisting of only 1’s and 0’s) matrix such that every square submatrix of size m × m of this matrix contains at least one zero.Consider the followi...原创 2019-09-04 15:31:13 · 184 阅读 · 0 评论 -
「BZOJ1303」[CQOI2009] 中位数图(中位数)
Description给出1~n的一个排列,统计该排列有多少个长度为奇数的连续子序列的中位数是b。中位数是指把所有元素从小到大排列后,位于中间的数。Input第一行为两个正整数n和b ,第二行为1~n 的排列。Output输出一个整数,即中位数为b的连续子序列个数。Sample Input7 45 7 2 4 3 1 6Sample Output4Hint第三个样例解释:{...原创 2019-10-02 12:26:49 · 191 阅读 · 0 评论 -
C - Fear Factoring Gym - 101615C(求约数和,除法分块)
Problem C — limit 1 secondFear FactoringThe Slivians are afraid of factoring; it’s just, well, difficult.Really, they don’t even care about the factors themselves, just how much they sum to.We can...原创 2019-10-02 18:42:52 · 353 阅读 · 1 评论 -
大连2016 F - Detachment HDU - 5976(贪心,数论,猜结论)
In a highly developed alien society, the habitats are almost infinite dimensional space.In the history of this planet,there is an old puzzle.You have a line segment with x units’ length representing...原创 2019-10-08 20:06:31 · 285 阅读 · 0 评论 -
Gerald and Giant Chess CodeForces - 559C(组合数逆元,神奇dp)
Giant chess is quite common in Geraldion. We will not delve into the rules of the game, we’ll just say that the game takes place on an h × w field, and it is painted in two colors, but not like in che...原创 2019-08-21 22:35:21 · 320 阅读 · 0 评论 -
1192: [HNOI2006]鬼谷子的钱袋(数学推理)
1192: [HNOI2006]鬼谷子的钱袋Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 5728 Solved: 3850[Submit][Status][Discuss]Description鬼谷子非常聪明,正因为这样,他非常繁忙,经常有各诸侯车的特派员前来向他咨询时政。有一天,他在咸阳游历的时候,朋友告诉他在咸阳最大的拍卖行(聚宝...原创 2019-08-20 23:30:13 · 219 阅读 · 0 评论 -
F - Mafia CodeForces - 348A(推公式)
One day n friends gathered together to play “Mafia”. During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many ...原创 2019-08-15 20:45:24 · 302 阅读 · 0 评论 -
Disgruntled Judge UVA - 12169(数学,枚举)
Once upon a time, there was an NWERC judge with a tendency to create slightly too hard problems. Asa result, his problems were never solved. As you can image, this made our judge somewhat frustrated....原创 2019-08-13 20:32:27 · 142 阅读 · 0 评论 -
Minimum Sum LCM UVA - 10791(唯一分解定理)
LCM (Least Common Multiple) of a set of integers is defined as the minimum number, which is amultiple of all integers of that set. It is interesting to note that any positive integer can be expressed...原创 2019-08-13 22:35:42 · 164 阅读 · 0 评论 -
GCD XOR UVA - 12716(推公式)
Given an integer N, find how many pairs (A, B) are there such that: gcd(A, B) = A xor B where1 ≤ B ≤ A ≤ N.Here gcd(A, B) means the greatest common divisor of the numbers A and B. And A xor B is the...原创 2019-08-13 23:25:22 · 186 阅读 · 0 评论 -
快速乘模板 / 三种方法 ACWING90. 64位整数乘法
求 a 乘 b 对 p 取模的值。输入格式第一行输入整数a,第二行输入整数b,第三行输入整数p。输出格式输出一个整数,表示a*b mod p的值。数据范围1≤a,b,p≤1018输入样例:345输出样例:2快速乘模板#include <cstdio>#include <cmath>#include <algorithm>#inc...原创 2019-08-13 23:50:02 · 259 阅读 · 0 评论 -
96. 奇怪的汉诺塔(递推,汉诺伊塔推广)
https://www.acwing.com/problem/content/description/98/汉诺塔问题,条件如下:1、这里有A、B、C和D四座塔。2、这里有n个圆盘,n的数量是恒定的。3、每个圆盘的尺寸都不相同。4、所有的圆盘在开始时都堆叠在塔A上,且圆盘尺寸从塔顶到塔底逐渐增大。5、我们需要将所有的圆盘都从塔A转移到塔D上。6、每次可以移动一个圆盘,当塔为空塔或者塔...原创 2019-08-14 14:36:26 · 489 阅读 · 0 评论 -
97. 约数之和
假设现在有两个自然数A和B,S是AB的所有约数之和。请你求出S mod 9901的值是多少。输入格式在一行中输入用空格隔开的两个整数A和B。输出格式输出一个整数,代表S mod 9901的值。数据范围0≤A,B≤5×107输入样例:2 3输出样例:15注意: A和B不会同时为0。难度: 中等时/空限制: 1s / 64MB总通过数: 535总尝试数: 1535来源...原创 2019-08-14 16:22:37 · 201 阅读 · 0 评论 -
codeforces1207D - Number Of Permutations
D. Number Of Permutationstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a sequence of原创 2019-08-23 20:44:49 · 778 阅读 · 6 评论 -
1008: [HNOI2008]越狱(排列组合)
Description 监狱有连续编号为1…N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可能信仰其中一种。如果相邻房间的犯人的宗教相同,就可能发生越狱,求有多少种状态可能发生越狱Input 输入两个整数M,N.1<=M<=108,1<=N<=1012Output 可能越狱的状态数,模100003取余Sample Input2 3Sampl...原创 2019-08-24 21:01:34 · 310 阅读 · 0 评论 -
D - Rational Resistance CodeForces - 343A(数学)
Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resistance value.However, all Mike has is lots of identical resistors with unit...原创 2019-08-15 20:03:26 · 163 阅读 · 0 评论 -
Colossal Fibonacci Numbers! UVA - 11582 (找循环节)
Oooh…prettyThe i’th Fibonacci number f(i) isrecursively defined in the followingway:• f(0) = 0 and f(1) = 1• f(i + 2) = f(i + 1) + f(i) forevery i ≥ 0Your task is to compute somevalues of this...原创 2019-08-13 19:30:13 · 141 阅读 · 0 评论