- 博客(22)
- 收藏
- 关注
原创 hdu 6061 RXD and functions [快速数论变换]
RXD has a polynomial function f(x)f(x), f(x)=∑ni=0cixif(x)=∑i=0ncixi RXD has a transformation of function Tr(f,a)Tr(f,a), it returns another function gg, which has a property that g(x)=f(x−a)g(x)=f(x−a). Given a1,a2,a3,…,ama1,a2,a3,…,am, RXD generates a
2017-08-02 20:02:19 333
原创 NTT(快速数论变换)用到的各种素数及原根
g是mod(r * 2 ^ k + 1)的原根r * 2 ^ k + 1rkg31125122171439735
2017-08-02 11:06:38 9168
原创 hdu 6058 Kanade's sum [区间第k大数求和] [2017 Multi-University Training Contest - Team 3]
点击打开题目题意:给你一个序列, 求每个区间的第k大的数的和, 如果不存在第k大的数, 则这个数为0.分析:一个很直观的思路就是算每个数的贡献, 对于这个序列中的数$a_i$, 枚举有多少区间第k大的数为$a_i$.*往前枚举找到k - 1个比$a_i$大的数,往后枚举找到k - 1个比$a_i$大的数. 然后将左边第i大的数到第i + 1大(包含i但不
2017-08-01 23:19:52 425
原创 UVALive - 7715 Guessing Game
点击打开题目题意:给出A1,A2,B1,B2,C1,C2,N,问有多少种方法使得A1 分析:要使A+B+C = N,即求A+B = N-C有多少种解法,那么N-C有一个取值范围[l, r],且这个区间的一个值唯一对应一个C值,那么现在就是求A+B = K(K = N-C)有多少种取值了先看这样一个例子, A1 = 0, A2 = 2,B1 = 1, B2 = 6的情况,
2017-07-31 20:11:33 310
原创 hdu 6041 I Curse Myself [2017 Multi-University Training Contest - Team 1]
点击打开题目题意:给你一个仙人掌图,求前K小的生成树的权值之和.分析:由于图是一个仙人掌,所以显然对于图上的每一个环都需要从环上取出一条边删掉。所以问题就变为有M个集合,每个集合里面都有一堆数字,要从每个集合中选择一个恰好一个数加起来。求所有的这样的和中,前K大的是哪些[求前k大/小:算法竞赛入门经典-训练指南189页]。#include#include#inclu
2017-07-30 19:11:13 243
原创 Gym - 101194F Mr. Panda and Fantastic Beasts [2016-2017 ACM-ICPC CHINA-Final] [后缀数组]
点击打开题目题意: 求第一个字符串在其他字符串中未出现过的最短, 且字典序最小的子串.分析: 先将所有子串用特殊字符串连接起来, 用后缀数组算出子串的sa数组和lcp高度数组, 然后从后往前遍历, 遇到长度更小的更新答案即可. #include#include#include#include#include#include#includetypedef l
2017-07-29 13:07:53 777
原创 Gym - 101194E Bet [2016-2017 ACM-ICPC CHINA-Final E][贪心]
点击打开题目题意: 有n个球队比赛,你可以赌哪个队获胜.如果你下注的队赢了,你将获得c + ai / bi * ci的钱,如果输了,那么你将输ci (ci为你下注的钱数).问, 在确保你一定能得到比原来钱数多的前提下,你最多可以赌多少个队获胜(你下注的队伍至少有一支会赢得比赛).分析: 假设原来总共有1元钱,在第i个足球队下注ci元钱,那
2017-07-29 11:24:39 963
原创 hdu 6051 If the starlight never fade [欧拉函数] [2017 Multi-University Training Contest - Team 2]
If the starlight never fadeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 104 Accepted Submission(s): 50Problem DescriptionW
2017-07-28 11:50:28 691
原创 hdu 6053 TrickGCD [2017 Multi-University Training Contest - Team 2] [莫比乌斯函数]
[容斥][莫比乌斯]题意: 给你一个序列a,求满足对于所有l, r都有gcd(b[l], ... , b[r]) >= 2并且bi 分析: 先枚举gcd的值, 然后利用前缀和快速算出a[i]/g = c(c = 1, 2, 3, ...)的个数, 然后用快速幂, 快速算出gcd为g的时候的值, 最后用容斥筛选一下.
2017-07-27 21:21:08 230
原创 中国剩余定理 [mi不互质]
假设有如下方程: 合并可得: 然后利用扩展欧几里得算法, 算出x1的最小正整数解, 代入原方程即可得y的值, 然后求出最终答案应用: http://blog.csdn.net/hnust_xx/article/details/76130227struct P { ll as, lc; ///as为ai, lc为最小公倍数
2017-07-26 20:53:21 291
原创 输入挂
int Scan() { int res = 0, ch, flag = 0; if((ch = getchar()) == '-') flag = 1; else if(ch >= '0' && ch <= '9') res = ch - '0'; while((ch = getchar()) >= '0
2017-07-26 20:33:20 213
原创 hdu 6040 Hints of sd0061[2017 Multi-University Training Contest - Team 1] [STL]
题目链接题意: 求a数组的第b[i]大数分析: (1)首先要了解c++中求第k大数的STL函数nth_element(start,start + n, end); 这个函数可以使数组第n大元素处于第n位置(从0开始,其位置是下标为 n的元素),并且比这个元素小的元素都排在这个元素之前,比这个元素大的元素都排在这个元素之后,但不能保证他们是有序的. 复杂度为O(n).(2
2017-07-26 20:30:03 251
原创 hdu 6004 Periodical Cicadas [2016 CCPC-Final F] [同余]
hdu 6004 Periodical Cicadas[2016 CCPC-Final F] [同余];
2017-07-26 10:56:34 1073 6
原创 fzu 2281 Trades [第八届福建省大学生程序设计竞赛 Problem J Trades] [贪心]
fzu 2281 Trades [第八届福建省大学生程序设计竞赛 Problem J Trades] [贪心]This is a very easy problem.ACMeow loves GTX1920. Now he has m RMB, but no GTX1920s. In the next n days, the unit price of GTX1920 in the ith day is Ci RMB. In other words, in the ith day, he can b
2017-07-24 09:10:00 772
原创 fzu 2277 Change [第八届福建省大学生程序设计竞赛 Problem F] [线段树]
点击打开题目题意: 给定一棵根为1, n个结点的树. 有q个操作,有两种不同的操作(1) 1 v k x : a[v] += x, a[v '] += x – k(v '为v的儿子), a[v ' '] += x – 2 * k(v ' '是v '的儿子) ... ;(2) 2 v : 输出a[v] % (1e9 + 7); 分析: 先dfs遍历, 得到这棵树的
2017-07-23 15:42:42 1217
原创 fzu 2275 Game [第八届福建省大学生程序设计竞赛 Problem D] [字符串匹配]
fzu 2275 Game第八届福建省大学生程序设计竞赛 Problem D [字符串匹配]链接: http://acm.fzu.edu.cn/contest/problem.php?cid=156&sortid=4题意: 对一个数字有两种操作: (1) 反转, (2) 除以 10 取整. 给你A, B 两个数, Alice只能操作数字A, Bob只能操作数字B, 如果Alice或Bob执行某次操作后A = B, Alice赢, 否则就一直执行下去.分析: 由于A, B<= 10
2017-07-22 21:17:02 482
原创 fzu 2278 YYS [第八届福建省大学生程序设计竞赛 Problem G] [概率]
第八届福建省大学生程序设计竞赛 Problem G YYS;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 new card, you need to pay W coins to draw a card. Each time you can only d
2017-07-22 20:52:41 1274 1
原创 LightOJ - 1104 Birthday Paradox [概率]
LightOJ - 1104 Birthday Paradox [概率];Birthday Paradox Sometimes some mathematical results are hard to believe. One of the common problems is the birthday paradox. Suppose you are in a party where there are 23 people including you. What is the probabili
2017-07-20 10:25:01 303
原创 LightOJ 1248 Dice (III) [期望]
LightOJ 1248 Dice (III) [期望];Given a dice with n sides, you have to find the expected number of times you have to throw that dice to see all its faces at least once. Assume that the dice is fair, that means when you throw the dice, the probability of occ
2017-07-20 09:26:08 375
原创 LightOJ 1038 Race to 1 Again [概率dp]
lightoj 1038 Race to 1 Again [概率dp];Rimi learned a new thing about integers, which is - any positive integer greater than 1 can be divided by its divisors. So, he is now playing with this property. He selects a number N. And he calls this D.In each turn
2017-07-20 08:49:21 247
原创 uva 1635 Irrelevant Elements [组合数, 唯一分解定理]
uva1635 Irrelevant Elements; 唯一分解定理; 组合数;Young cryptoanalyst Georgie is investigating different schemes of generating random integer numbersranging from 0 to m − 1. He thinks that standard random number generators are not good enough, sohe has invented
2017-07-19 21:11:07 251
原创 xtu 1260 Determinant [2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛(湖南) A题]
xtu 1260 Determinant [2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛(湖南) A题];Bobo learned the definition of determinant det(A) of matrix A in ICPCCamp. He also knew determinant can be computed in O(n3) using Gaussian Elimination.Bobo has an (n−1)×n matrix B he would li
2017-07-19 21:06:56 470
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人