随笔分类 -  前缀和

摘要:time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Every Codeforces user has rating, de... 阅读全文
posted @ 2017-10-04 18:45 AWCXV 阅读(224) 评论(0) 推荐(0)
摘要:time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Kleofáš is participating in an n-thlo... 阅读全文
posted @ 2017-10-04 18:45 AWCXV 阅读(163) 评论(0) 推荐(0)
摘要:time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output Two soldiers are playing a game. At ... 阅读全文
posted @ 2017-10-04 18:45 AWCXV 阅读(163) 评论(0) 推荐(0)
摘要:Submissions:587Solved:182DESCRIPTION In a mysterious cave, PigVan ( Mr.Van’s pet ) has lived for thousands years. PigVan absorbed the power of... 阅读全文
posted @ 2017-10-04 18:45 AWCXV 阅读(110) 评论(0) 推荐(0)
摘要:time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Arthur has bought a beautiful big tab... 阅读全文
posted @ 2017-10-04 18:45 AWCXV 阅读(282) 评论(0) 推荐(0)
摘要:【题目链接】:http://noi.qz5z.com/viewtask.asp?id=z05【题解】 显然w越大,最后的Y也就越大; 可以依靠这个搞二分; 如果二分枚举的tw得到的Y比S小,则减小tw以增大Y,否则增大tw就好; 那个区间的和可以用前缀和搞出来(确定当前的tw然... 阅读全文
posted @ 2017-10-04 18:45 AWCXV 阅读(123) 评论(0) 推荐(0)
摘要:(hotel.cpp/c/pas) 【问题描述】 丽江河边有n 家很有特色的客栈,客栈按照其位置顺序从 1 到n 编号。每家客栈都按照 某一种色调进行装饰(总共 k 种,用整数 0 ~ k-1 表示),且每家客栈都设有一家咖啡店,每 家咖啡店均有各自的最低消费。 两位游客一起去丽江旅... 阅读全文
posted @ 2017-10-04 18:45 AWCXV 阅读(128) 评论(0) 推荐(0)
摘要:【题目链接】:https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2129【题意】 【题解】 NMB 直接说i-1,i-2,i-3不就好了… 【Number Of WA】 0 【完整代码】#include using namesp... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(177) 评论(0) 推荐(0)
摘要:【题目链接】:http://codeforces.com/contest/509/problem/E【题意】 让你计算一个字符串的所有子串里面元音字母出现的频率的和; 【题解】 先处理出前缀和->pre[i]->前i个字母里面元音字母的个数; 设ans[i] 表示长度为i的子串出... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(105) 评论(0) 推荐(0)
摘要:【题目链接】:http://hihocoder.com/problemset/problem/1502【题意】 【题解】 枚举矩形的最上面的行数和最下面的行数(i,j且iusing namespace std;#define lson l,m,rt= b;i--)#define m... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(105) 评论(0) 推荐(0)
摘要:【链接】h在这里写链接【题意】定义bad list是一个非空的、最大公约数为1的序列。给定一个序列,有两种操作:花费x将一个元素删除、花费y将一个元素加1,问你将这个序列变为good list所需要的最小花费是多少。【题解】枚举gcd为i.这里的枚举,并不是说确切这些数字的gcd就是i;而是枚举这些... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(178) 评论(0) 推荐(0)
摘要:【Link】:http://codeforces.com/contest/835/problem/C【Description】 给你n个星星的坐标(xi,yi); 第i个星星在第t秒,闪烁值变为(si+t)%(c+1); 给你q个询问,每个询问由时间t和一个矩形的左下角和右上角组成... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(127) 评论(0) 推荐(0)
摘要:【Link】:【Description】 给你一个n*m的格子; 然后里面零零散散地放着葡萄 让你把它切成若干个小矩形方格 使得每个小矩形方格都恰好包含有一个葡萄. 要求切的长度最短; 问最短的切割距离; 【Solution】 记忆化搜索; 先枚举位点竖着切; 再枚举位点横着切 ... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(105) 评论(0) 推荐(0)
摘要:【Link】:http://www.ifrog.cc/acm/problem/1143?contest=1020&no=0【Description】 【Solution】 因为每个点的(xi,yi)里面, 0using namespace std;#define lson l,m,... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(110) 评论(0) 推荐(0)
摘要:【题目链接】:https://csacademy.com/contest/round-36/task/safe-spots/【题意】 给你n个数字构成的序列; 每个位置上的数都由0和1组成; 对于每个0; 假设其位置为i; 如果[i-k..i+k]这个范围内1的个数不超过1,则称它... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(152) 评论(0) 推荐(0)
摘要:【题目链接】:http://codeforces.com/contest/816/problem/B【题意】 给你很多个区间[l,r]; 1=k则i是一个特殊数字; 写个前缀和O(1)输出答案. 【Number Of WA】 0 【完整代码】#include using na... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(127) 评论(0) 推荐(0)
摘要:【题目链接】:http://acm.hdu.edu.cn/showproblem.php?pid=4135【题意】 让你求出[a..b]这个区间内和N互质的数的个数; 【题解】 利用前缀和,求出[1..a-1]和a[1..b]这两个区间内和N互质的数的个数; 方法是; 从小到大求... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(71) 评论(0) 推荐(0)