[Codeforces 863E]Turn Off The TV】的更多相关文章

Description Luba needs your help again! Luba has n TV sets. She knows that i-th TV set will be working from moment of time li till moment ri, inclusive. Luba wants to switch off one of TV sets in order to free the socket. Let's call some TV set redun…
http://codeforces.com/contest/863/problem/E 注意细节 #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <time.h> #include <string> #include <set> #include <map> #include <list&g…
传送门 除了操作 \(3\) 都可以 \(bitset\) 现在要维护 \[C_i=\sum_{gcd(j,k)=i}A_jB_k\] 类比 \(FWT\),只要求出 \(A'_i=\sum_{i|d}A_d\) 就可以直接按位相乘了 求答案就是莫比乌斯反演,\(A_i=\sum_{i|d}\mu(\frac{d}{i})A'_i\) 把每个数字的 \(\mu\) 的 \(bitset\) 预处理出来,乘法就是 \(and\) 最后用 \(count\) 统计答案 # include <bits…
题意:有n个可重集合,有四种操作: 1:把一个集合设置为单个元素v. 2:两个集合求并集. 3:两个集合中的元素两两求gcd,然后这些gcd形成一个集合. 4:问某个可重复集合的元素v的个数取模2之后是多少. 思路:因为集合的元素是对2取模,那么我们可以用bitset来代替可重复集合.但是,如果每个bitset来直接代表多重集的话,第三个操作会很麻烦.所以我们每个集合的bitset用来代表每个元素和每个元素约数的集合,这样某个约数为标记为1说明这个约数的倍数的和为奇数(这个约数的倍数就是这个元素…
传送门 由于只要考虑 $\mod 2$ 意义下的答案,所以我们只要维护一堆的 $01$ 容易想到用 $bitset$ 瞎搞...,发现当复杂度 $qv/32$ 是可以过的... 一开始容易想到对每个集合开一个 $bitset$ ,叫 $cnt[]$ ,维护各种值的数出现了奇数还是偶数次 因为要维护那个奇怪的 $3$ 操作,所以改成维护各种值的倍数出现了奇数还是偶数次,即 $cnt[x]$ 维护集合内所有 $x|d$ 的数 $d$ 的出现次数 那么对于操作 $3$,$x$ 的倍数和 $y$ 的倍数…
Description 你需要维护 \(n\) 个可重集,并执行 \(m\) 次操作: 1 x v:\(X\leftarrow \{v\}\): 2 x y z:\(X\leftarrow Y \cup Z\): 3 x y z:\(X \leftarrow \{\gcd(a, b)\ |\ a\in Y, b\in Z\}\): 4 x v:询问 \(v\) 在 \(X\) 中出现次数 \(\bmod 2\) 的结果. Hint \(1\le n\le 10^5, 1\le m\le 10^6…
1.Quasi-palindrome 题意:问一个字符串(你可以添加前导‘0’或不添加)是否是回文串 思路:将给定的字符串的前缀‘0’和后缀‘0’都去掉,然后看其是否为回文串 #include<iostream> using namespace std; int main() { int num; scanf("%d", &num); != && num % == ) num /= ; ; int tnum = num; while (tnum) {…
Season 1, Episode 22: Flight -Franklin: You know you got a couple of foxes in your henhouse, right? fox: 狐狸 henhouse: 鸡舍 你的队伍里都是一群狐狸 -Michael: They both want out of here. both: 两者都 他们都想出去 They'll behave until then. behave: 举止端正 出去前都会安分的 -Franklin: Lo…
The most difficult aspect of running Nettuts+ is accounting for so many different skill levels. If we post too many advanced tutorials, our beginner audience won’t benefit. The same holds true for the opposite. We do our best, but always feel free to…
目录 · Strategy · When to use the Strategy Design Pattern? · Sample Code · Observer · When to use the Observer Design Pattern? · Sample Code · Command · What is the Command Design Pattern? · Benefits of the Command Design Pattern. · Sample Code · Templ…
In this lesson you will learn to talk about past occurences. 过去进行时 课上内容(Lesson) C: Hi, Loki! L: Hi, Corrine.Good evening! L: Long time no see. C: Yeah, How is evething? L: Oh, I had a holiday last week     # 这里的had 是have 的过去形式 C: How do you feel when…
 std::bitset 的语法就不搬运了, 直接看题吧   #515. 「LibreOJ β Round #2」贪心只能过样例 题意: 给出 n 个数 \(x_i\), 每个数的取值范围为 \([a_i, b_i]\), 求 \(\sum{x_i}\) 的种类数. \(1 ≤ n ≤ 100, 1 ≤ a_i, b_i ≤ 100\). 思路: 直接状压的话需要枚举每个状态, 有了 bitset 之后就可以整体右移来转移了. view code #include <bits/stdc++.h>…
链接: https://codeforces.com/contest/1247/problem/B2 题意: The only difference between easy and hard versions is constraints. The BerTV channel every day broadcasts one episode of one of the k TV shows. You know the schedule for the next n days: a sequen…
Problem I. TV ShowTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88926#problem/I Description Charlie is going to take part in one famous TV Show. The show is a single player game. Initially the play…
传送门 https://www.cnblogs.com/violet-acmer/p/10005351.html 题意: 有n个节目,每个节目都有个开始时间和结束时间. 定义x,y分别为租电视需要的花费和看电视需要的花费(应该是花的电费,哈哈). 加入某电视节目的播放区间是[a,b],那么看完这个节目需要的总花费为x+(b-a)*y. 如果有其他节目的播放区间是[b,c],那么便不能和[a,b]的节目用同一个电视看. 求看完所有电视节目所需要的最少花费. 题解: 这应该是道贪心题. 对于每个节目…
Alex decided to try his luck in TV shows. He once went to the quiz named "What's That Word?!". After perfectly answering the questions "How is a pseudonym commonly referred to in the Internet?" ("Um... a nick?"), "After…
Bryce1010模板 http://codeforces.com/contest/1008/problems #include <bits/stdc++.h> using namespace std; #define ll long long const int MAXN=1e5+10; const int INF=0x3f3f3f3f; struct REC { int w,h; }rec[MAXN]; int n; int main() { //cout << "H…
B2. TV Subscriptions (Hard Version) The only difference between easy and hard versions is constraints. The BerTV channel every day broadcasts one episode of one of the k TV shows. You know the schedule for the next n days: a sequence of integers a1,a…
题目链接: https://codeforces.com/gym/101987 题意: 有长度为$n$的只包含$B,R$的字符串 有m种关系,每个关系说出三个位置的确切字符 这三个位置的字符最多有一个是错的 数据范围: $1\leq n \leq 5000$ $1\leq m \leq 10000$ 分析: 比如给出1B 2R 3B 那么如果1是R,2必须是R,3必须是B 如果2是B,1必须是R,3必须是B 如果3是R,1必须是B,2必须是R 对这些关系建立2—SAT模型 1B的编号为1,1R的…
题意 ABC的位置关系只有三种可能: 1.在一条直线上,输出TOWARDS A--B--C 2.AB 和BC垂直,B为直角顶点,AB左侧是C,输出LEFT C--B | A 3.AB 和BC垂直,B为直角顶点,AB右侧是C,输出RIGHT B --C | A 给你ABC三点的坐标,求背朝A,站在B点,往C走要前进还是左转还是右转. 分析 假定ABC的坐标:A(xa,ya),B(xb,yb),C(xc,yc),粗体表示向量. BA为(x1,y1)=(xa-xb,ya-yb) BC为(x2,y2)=…
题意:给出n个电视节目的起始和结束时间  并且租一台电视需要x +y*(b-a)  [a,b]为时段 问完整看完电视节目的最小花费是多少 思路:贪心的思想 情况1 如果新租一台电视的花费<=在空闲电视上面看节目 那么肯定新租电视 情况2 否则就直接在空闲电视上看 就好 模拟难(QAQ): 这里使用多重集合模拟   先把所有时间的pair(结束时间,开始时间) 放入多重集里面 然后开一个数组以l 从小到大排序 从数组小到大 枚举  在多重集里面找离终点最近的那个点 如果符合情况1 那么就删去 找到…
题意:n个节目,每个节目的播放时间为[li,ri],你需要选择一些电视机全部播放这些节目,一台电视机不能同时播放多个节目,选择一个新的电视机代价为x , 如果某台电视机的使用时间为[Li,Ri]需要付出(Ri-Li)*y的代价,问最小的代价: 题解:        答案是选由于使用电视播放节目的代价是固定的,所以只需要让浪费的使用时间和选择一个新的电视的代价之和最小即可,左端点排序,对于[li,ri],每次选择前面使得rj<li的rj最大的(lj,rj),将x和(li-rj)*y比较讨论: cf…
A. Soldier and Bananas   A soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay i·k dollars for the i-th banana). He has n dollars. How many d…
连接在这里,->点击<- A. Bear and Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and ther…
A.Toda 2 思路:可以有二分来得到最后的数值,然后每次排序去掉最大的两个,或者3个(奇数时). /************************************************ *Author* : Ray(siludose) *Created Time* : 2016��10��24�� ����һ 15ʱ00��28�� **Problem** : /media/ray/708898B888987E72/Users/Administrator/Desktop/2016…
今天,开博客,,,激动,第一次啊 嗯,,先来发水题纪念一下 D1. Magic Powder - 1   This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a single solution to the both versions. If you fin…
Guess a number! Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the sho…
Inna and Alarm Clock Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Inna loves sleeping very much, so she needs n alarm clocks in total to wake up. Let's suppose that Inna's room is a 100 × 100 …
D. Equivalent Strings Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/problem/B Description Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are…
Problem A. Poetry Challenge Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/attachments Description Let’s check another challenge of the IBM ICPC Chill Zone, a poetry challenge. One says a poetry string that starts with a…