Codeforces Round #284 (Div.1) Solution

A 有意思,初看觉得怎么A还要求线交还这么麻烦。仔细一想。每次只能过一条线。如果有一条线在两点间,则必须过它们。在同侧的线不需要过。于是就简单了。

B 时限好紧,我用了一个诡异的方法的时间复杂也是O(nT)却超了。

C 奇数和偶数显然形成了二分图。对每一个素因子来一次最大流。

D 首先注意到模LCM的60,噢。由于之前那个题,一下就想到分块大法好。什么嘛,明明就可以线段树呀。

时间: 2024-07-28 18:10:55

Codeforces Round #284 (Div.1) Solution的相关文章

Codeforces Round #284 (Div. 2) b

/**  * @brief Codeforces Round #284 (Div. 2) b  * @file b.cpp  * @author mianma  * @created 2014/12/26 11:51  * @edited  2014/12/18 11:51  * @type brute  * @note  */ #include <fstream> #include <iostream> #include <string> #include <c

[Codeforces Round #284 (Div. 1) B]Name That Tune(概率Dp)

Description It turns out that you are a great fan of rock band AC/PE. Peter learned that and started the following game: he plays the first song of the list of n songs of the group, and you have to find out the name of the song. After you tell the so

Codeforces Round #275 (Div.1) Solution

好久没做题了,开场Virtual热热身. A 构造,我的方法是,取1,2,3...,k这几个差值,前k+1个数分别是 1, k+1, 2, k, ...., 之后就k+2, k+3, ..., n B 因为题设是与操作.我们按照每一位来,如果有一个限制某位是1,则将那段区间标志1,没有限制的位全部置零即可,然后检验为0的位是否全是1.标志一段区间可以用标记法,检验可以求和看差值. C 我做完之后看了CF tutorial 跟我的做法不同.我的做法比他给的复杂度低一点,不过题解好帅,而且跑出来速度

Codeforces Round #282 (Div.1) Solution

上午考试,下去去参观教堂,回来睡大觉,搞到现在才有时间做,水平恢复中. A 倒过来扫括号匹配很容易理解 B dp[i]表示最后一个拿到i的数目,sum[i]表示前i项dp和,sum2[i]表示前i项sum和.显然.dp[i]=sum2[o], o是最右边的坐标使得s[o+1,i]能包含t. C Interesting,我建了个树,硬着dp搞得..还没优化就46ms,想来这种题数据也不好构造. D Editorial似乎说离线搞,不过我在线搞出来了.我存了每个节点子树平方和,子树和,整体和,整体平

[比赛] Codeforces Round #538 (Div. 2) solution (贪心,数学其他,二分,线段树)

已经写了100篇题解啦! link solution pdf #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; inline int read(){ int f=1,ans=0;char c; while(c<'0'||c>'9'){if(c=='-')f=-1;c

Codeforces Round #607 (Div. 1) Solution

从这里开始 比赛目录 我又不太会 div 1 A? 我菜爆了... Problem A Cut and Paste 暴力模拟一下. Code #include <bits/stdc++.h> using namespace std; typedef bool boolean; const int N = 1e6 + 5; const int Mod = 1e9 + 7; int T; int x; int len; char s[N]; int paste(int s1, int t1, in

Codeforces Round #284 (Div. 2) C题(计算几何)解题报告

题目地址 简要题意: 给出两个点的坐标,以及一些一般直线方程Ax+B+C=0的A.B.C,这些直线作为街道,求从一点走到另一点需要跨越的街道数.(两点都不在街道上) 思路分析: 从一点到另一点必须要跨的街道等价于两点一点在这条直线一侧,另一条在另一侧.只需要将两点坐标带进去,一正一负即可.将这些直线依次检验,统计总和. 1 #include<stdio.h> 2 #include<bits/stdc++.h> 3 #include <iostream> 4 using

Codeforces Round #284 (Div. 2) A

解题思路:给出 n个电影的精彩时段(a[i],b[i]),和每次可以跳过的时间x,问要看完所有的精彩时刻,至少需要看多长时间的电影. 因为要时间最少,所有除了精彩时刻的电影则能跳过就跳过(用取余来算),不能跳过则加到耗费的总时间里面. 反思:WA两次是因为没有搞清楚物理上的时刻和时间的关系, -------------------------------------------------- 1    2     3     4      5      6       7       8 如果我

Codeforces Round #268 (Div. 1) solution

A.24 Game 题意:给你1, 2, ..., n-1, n 这个序列,每次你可以取出两个数做+/-/*三种操作之一,然后把结果放回到序列中,询问能否是的这个序列最后只剩下一个24. 解法:首先很明显n < 4的时候是无解的.如果n=4,那么1 * 2 * 3 * 4=24,如果n=5,那么(5 - 1 - 2) * 3 * 4 = 24.若n > 5,那么我可以做n - (n - 1) = 1,相当于变成了n-2时候的情况加一个1,那么显然最后让答案乘上这个1即可. 代码: includ