ACM
关于ACM训练中数学题目的讲解
绝尘花遗落
一骑红尘妃子笑,无人知是荔枝来
展开
-
2018年百度之星资格赛部分题解
1001调查问卷题解由于每个问卷的问题只有两个选项,并且m≤10m≤10m\le10那么所有问题的状态为210=1024210=10242^10 = 1024种答案,n≤103n≤103n\le 10^3,那么直接枚举保留问题的状态暴力计算就行#include <bits/stdc++.h>using namespace std;char s[11];in...原创 2018-08-06 15:14:13 · 945 阅读 · 0 评论 -
101Hack44
Hackerrank101hack44Picking NumbersAlice and Bob's Silly GameExpected Tree LeavesPalindromic Subsets原创 2016-12-15 12:06:59 · 514 阅读 · 0 评论 -
【BZOJ2844】albus就是要第一个出场——线性基
Time Limit: 6 Sec Memory Limit: 128 MBDescription已知一个长度为n的正整数序列A(下标从1开始), 令 S = { x | 1 <= x <= n }, S 的幂集2^S定义为S 所有子 集构成的集合。定义映射 f : 2^S -> Zf(空集) = 0f(T) = XOR A[t] , 对于一切t属于T现在albus把2^S中每个集 合的f值计原创 2016-11-14 00:21:39 · 494 阅读 · 0 评论 -
【Bzoj 2460 [BeiJing2011]】——元素 线性基+贪心
Description相传,在远古时期,位于西方大陆的 Magic Land 上,人们已经掌握了用魔 法矿石炼制法杖的技术。那时人们就认识到,一个法杖的法力取决于使用的矿石。 一般地,矿石越多则法力越强,但物极必反:有时,人们为了获取更强的法力而 使用了很多矿石,却在炼制过程中发现魔法矿石全部消失了,从而无法炼制 出法杖,这个现象被称为“魔法抵消” 。特别地,如果在炼制过程中使用超过 一块原创 2016-11-17 19:17:17 · 560 阅读 · 0 评论 -
【Bzoj4568: [Scoi2016]】幸运数字——LCA+线性基
Time Limit: 60 Sec Memory Limit: 256 MBDescriptionA 国共有 n 座城市,这些城市由 n-1 条道路相连,使得任意两座城市可以互达,且路径唯一。每座城市都有一个 幸运数字,以纪念碑的形式矗立在这座城市的正中心,作为城市的象征。一些旅行者希望游览 A 国。旅行者计划 乘飞机降落在 x 号城市,沿着 x 号城市到 y 号城市之间那条唯一的路径游览,原创 2016-11-20 01:22:52 · 674 阅读 · 0 评论 -
【Bzoj4184】 shallot——时间分治+线性基
Time Limit: 30 Sec Memory Limit: 128 MBDescription小苗去市场上买了一捆小葱苗,她突然一时兴起,于是她在每颗小葱苗上写上一个数字,然后把小葱叫过来玩游戏。每个时刻她会给小葱一颗小葱苗或者是从小葱手里拿走一颗小葱苗,并且 让小葱从自己手中的小葱苗里选出一些小葱苗使得选出的小葱苗上的数字的异或和最大。 这种小问题对于小葱来说当然不在话下,但是他的身原创 2016-11-23 13:07:53 · 865 阅读 · 0 评论 -
Network Wars-ZOJ2676最小割+01规划
Time Limit: 5 Seconds Memory Limit: 32768 KB Special JudgeNetwork of Byteland consists of n servers, connected by m optical cables. Each cable connects two servers and can transmit data in both dir原创 2016-02-26 09:30:24 · 1527 阅读 · 0 评论 -
OPTM-Optimal Marks-SPOJ839最小割
You are given an undirected graph G(V, E). Each vertex has a mark which is an integer from the range [0..231 – 1]. Different vertexes may have the same mark.For an edge (u, v), we define Cost(u, v) = m原创 2016-02-26 11:42:14 · 2083 阅读 · 0 评论 -
2016中国大学生程序设计竞赛 - 网络选拔赛
HDU【5832】——A water problemHDU【5833】——Zhu and 772002HDU【5834】——Magic boy Bi Luo with his excited treeHDU【5835】——DanganronpaHDU【5839】——Special TetrahedronHDU【5842】——Lweb and String原创 2016-08-14 21:28:35 · 1906 阅读 · 0 评论 -
BSGS
【BZOJ】3122:【Sdoi2013】-随机数生成器【Bzoj】2242: [SDOI2011]——计算器离散对数大步小步算法bsgs原创 2016-08-15 18:07:25 · 1302 阅读 · 0 评论 -
裴蜀定理
Bzoj【2257】: [Jsoi2009]——瓶子和燃料【Bzoj】2299: [HAOI2011]——向量原创 2016-08-15 21:56:19 · 2197 阅读 · 0 评论 -
【Uva10288】——Coupons概率
题意:一共有n种不同的Coupons,每次得到每种Coupons的概率是相同的,问期望多少次得到所有的n种Coupons假设我们已经得到k种Coupons,那么我们得到新的Coupons的概率为n−kn\frac{n-k}{n},所需的期望步数是nn−k\frac{n}{n-k}。求和我们得到总的期望步数nn+nn−1+⋯n1=n×∑i=1n1i\frac{n}{n}+\frac{n}{n-1}+\原创 2016-11-10 00:11:28 · 581 阅读 · 0 评论 -
第七届ACM山东省赛-G Triple Nim
Time Limit: 2000MS Memory limit: 65536KAlice and Bob are always playing all kinds of Nim games and Alice always goes first. Here is the rule of Nim game:There are some distinct heaps of stones. On each原创 2016-06-10 09:17:15 · 1292 阅读 · 0 评论 -
Codeforces 366 Div2
A. Hulk time limit per test 1 second memory limit per test 256 megabytesDr. Bruce Banner hates his enemies (like others don’t). As we all know, he can barely talk when he turns into the incredi原创 2016-08-08 08:44:58 · 955 阅读 · 3 评论 -
【UVA11538】Chess Queen——简单组合
题意:给你一个n×mn \times m 的棋盘,在上面放两个皇后,(一黑一白)问有多少种放的方法 分析:皇后的攻击的范围为同一行或者同一列或者在同一对角线,这三种情况没有交集,利用加法原理,对于同一行的放置数目为A(n,m)=n×m×(m−1)A(n,m) = n\times m\times (m-1),同一列的放置为B(m,n)=m×n×(n−1)B(m,n) = m\times n原创 2016-03-24 19:54:28 · 747 阅读 · 0 评论 -
【UVA11401】Triangle Counting——计算方法
题意:从 1,2,3⋯,n1,2,3\cdots ,n中选出三个不同的整数,使它们能够组成三角形,问有多少种方法 分析:设最长的边为xx,另外的两条边为y,z\quad y,z ,所以y+z>x\quad y+z>x,所以z的范围为x>z>x−yx>z>x-y 当y=1时,x>z>x−1显然无解当\quad y =1 时,x>z>x-1\quad 显然无解 当y=2时,x>z>原创 2016-03-24 20:55:24 · 851 阅读 · 0 评论 -
【UVA10325】The Lottery——简单容斥定理
题意:给你一个数组,问[1,n][1,n]中有多少个数不能整除数组的任何一个数 分析:对于这种问题,我们可以求其逆问题,就是在区间[1,n]中存在多少数可以整除数组中的只少一个数 对于a[i],可以整除它的数的数量为Ai=na[i],但是我们不能将每一个数的数量加起来,因为存在重复元素a[i],可以整除它的数的数量为A_i = \frac{n}{a[i]},但是我们不能将每一个数的数原创 2016-03-24 21:41:38 · 735 阅读 · 0 评论 -
【UVA11806】Cheerleaders——容斥
题意:给你一个n×mn \times m的矩阵网格和k个人,问有多少种方法使得每一个格子只放一个人,并且第一行,最后一行,第一列,最后一列都有人。 分析:如果没有限制条件,我们知道答案是ans=C(nm,k),但是有限制条件,我们定义A表示第一行没有人,B表示最后一行没有人,C表示第一列没有人,D表示最后一列没有人,我们可以得到答案是ans=ans−A−B−C−D+AB+AC+AD⋯+AB原创 2016-03-25 19:47:40 · 573 阅读 · 0 评论 -
【UVA11174】Stand in a Line——逆元+树形Dp
All the people in the byteland want to stand in a line in such a way that no person stands closer to the front of the line than his father. You are given the information about the people of the bytela原创 2016-03-27 19:53:19 · 569 阅读 · 0 评论 -
【UVA11426】GCD - Extreme (II)——欧拉函数
Given the value of N, you will have to find the value of G. The definition of G is given below: G=∑i=1n∑j=i+1nGCD(i,j)G= \sum\limits_{i=1}^{n} \sum\limits_{j=i+1}^nGCD(i,j) Here GCD(i, j) means the gr原创 2016-03-30 18:07:27 · 853 阅读 · 0 评论 -
Topcoder SRM 636 Div1 B
题意:给你一个矩阵,矩阵中有’.’和’#’,’.’表示空闲的地方,’#’表示非空闲的地方,现在有r个机器人,在空闲的地方等概率的选择一个空闲的地方。现在定义他们之间的关系,对于一个机器人,他和距离他最近的机器人有一条边,如果距离相等,那么选择列坐标小的,如果还相等,选择行坐标小的。所谓的距离为他们之间的欧几里得距离。对于选定位置的机器人,会形成r条边r个点的有向图,那么问在这些可能形成的图中连通分量原创 2016-06-03 16:44:11 · 418 阅读 · 0 评论 -
(POJ2635)The Embarrassed Cryptographer(大数取模)
The Embarrassed Cryptographer Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13041 Accepted: 3516Description The young and very promising cryptographer Odd Even has implement原创 2015-08-22 16:34:33 · 463 阅读 · 0 评论 -
Semi-prime H-numbers(筛法)
Semi-prime H-numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8069 Accepted: 3479DescriptionThis problem is based on an exercise of David Hilbert, who pedagogically suggest原创 2015-08-22 17:18:24 · 416 阅读 · 0 评论 -
Sumdiv(快速幂+约数和)
Sumdiv Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 16244 Accepted: 4044Description Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. D原创 2015-08-22 21:29:59 · 643 阅读 · 0 评论 -
C Looooops(扩展欧几里得)
C Looooops Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20128 Accepted: 5405Description A Compiler Mystery: We are given a C-language style for loop of typefor (variable =原创 2015-08-23 13:22:52 · 393 阅读 · 0 评论 -
Bi-shoe and Phi-shoe【lightoj1370】——欧拉数
Bamboo Pole-vault is a massively popular sport in Xzhiland. And Master Phi-shoe is a very popular coach for his success. He needs some bamboos for his students, so he asked his assistant Bi-Shoe to go原创 2016-05-05 17:01:30 · 531 阅读 · 0 评论 -
Maximum Value(哈希)
B. Maximum Value time limit per test 1 second memory limit per test 256 megabytes input standard input output standard outputYou are given a sequence a consisting of n integers. Find the maximu原创 2015-08-23 15:28:39 · 822 阅读 · 0 评论 -
【codefores 587 E】Duff as a Queen——线段树+线性基
time limit per test7 seconds memory limit per test256 megabytesDuff is the queen of her country, Andarz Gu. She’s a competitive programming fan. That’s why, when he saw her minister, Malek, free, she原创 2016-11-11 22:49:26 · 1616 阅读 · 1 评论 -
【HDU3949】XOR——线性基
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem DescriptionXOR is a kind of bit operator, we define that as follow: for two binary base number A and B, let C=A原创 2016-10-15 21:01:44 · 779 阅读 · 0 评论 -
2009 Multi-University Training Contest 1 - Host by TJU
【HDU2817】 - A sequence of numbers——快速幂+水题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem DescriptionXinlv wrote some sequences on the paper a long time ago,原创 2016-10-28 00:04:33 · 898 阅读 · 0 评论 -
【HDU1402】A * B Problem Plus——FFT初步
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionCalculate A×BA \times B.InputEach line will contain two integers A and B. Process to end of file.No原创 2016-11-19 18:41:35 · 475 阅读 · 0 评论 -
2013 Multi-University Training Contest 1
【4609HDU】3-idiots——组合计数+FFT Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem DescriptionKing OMeGa catched three men who had been streaking in the street. Lo原创 2016-11-20 10:28:59 · 610 阅读 · 0 评论 -
2015 Multi-University Training Contest 2
【HDU5307】He is Flying——FFT+母函数原创 2016-11-21 01:31:20 · 537 阅读 · 0 评论 -
【HDU5730】Shell Necklace——CDQ+FFT
【HDU5730】Shell Necklace——CDQ+FFT Time Limit: 16000/8000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Problem DescriptionPerhaps the sea‘s definition of a shell is the pearl. However, i原创 2016-11-22 11:08:17 · 757 阅读 · 0 评论 -
Round Numbers(组合数学)
Round Numbers Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10484 Accepted: 3831DescriptionThe cows, as you know, have no fingers or thumbs and thus are unable to play Scisso原创 2015-08-21 08:42:47 · 595 阅读 · 0 评论 -
Code(组合数学)
Code Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8766 Accepted: 4168Description Transmitting and memorizing information is a task that requires different coding systems for t原创 2015-08-21 09:19:54 · 396 阅读 · 0 评论 -
Paths on a Grid(简单组合数学)
Paths on a Grid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 23008 Accepted: 5683Description Imagine you are attending your math lesson at school. Once again, you are bored原创 2015-08-21 10:06:05 · 935 阅读 · 0 评论 -
POJ3420Quad Tiling(矩阵快速幂)
Quad TilingTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 3740 Accepted: 1684 DescriptionTired of the Tri Tiling game finally, Michael turns to a more challengeable game, Quad Ti原创 2015-12-29 18:50:41 · 1395 阅读 · 0 评论 -
【POJ2891】Strange Way to Express Integers——中国剩余定理(非互质)
Strange Way to Express Integers Time Limit: 1000MS Memory Limit: 131072KDescriptionElina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The原创 2016-04-02 10:57:49 · 802 阅读 · 0 评论 -
【POJ3101】Astronomy——分子的最小公倍数
AstronomyTime Limit: 2000MS Memory Limit: 65536KDescriptionThere are n planets in the planetary system of star X. They orbit star X in circular orbits located in the same plane. Their tangent velo原创 2016-04-04 10:53:33 · 1552 阅读 · 0 评论