题目链接:http://codeforces.com/contest/731/problem/D D. 80-th Level Archeology time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Archeologists have found a secret pass in the dungeon of one of t…
https://codeforces.com/contest/1114/problem/F 欧拉函数 + 区间更新线段树 题意 对一个序列(n<=4e5,a[i]<=300)两种操作: 1. 将a[l,r]的数字乘以x(x<=300) 2. 求\(\varphi(\prod_{i=l}^ra[i])\)对1e9+7取模 题解 欧拉函数性质 假如\(p\)是一个质数,\(\varphi(p)=p-1\),\(\varphi(p^k)=p^{k-1}*(p-1)=p^k*\frac{p-1}…
Socks Problem Description: Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes. Ten minutes before her…
题目链接:http://codeforces.com/contest/731/problem/F 题意:有n个数,从里面选出来一个作为第一个,然后剩下的数要满足是这个数的倍数,如果不是,只能减小为他的倍数,否则就舍弃掉,然后把没有舍弃的数的值加起来,求和的最大值; 43 2 15 9 就拿这个来说,当拿3当做第一个数时结果是3+15+9=27因为2不是3的倍数:当拿2作为第一个数时,结果是2+2+14+8=26因为3,15,9都不是2的倍数,所以只能减小;同理...求最大的和; 我们可以记录每个…
题目链接:http://codeforces.com/problemset/problem/731/C 题意:有n只袜子,每只都有一个颜色,现在他的妈妈要去出差m天,然后让他每天穿第 L 和第 R 只袜子,他为了让每天穿的袜子都是一个颜色的,他需要把袜子涂色,共有k种颜色,求最少需要涂多少只袜子,才能保证他每天穿的袜子都是一样的. 用并查集把所有联系在一起的袜子放到一个集合中去,然后这些袜子会变成一块一块的,我们在每一块中找一种颜色最多的,然后把当前块中的其他袜子都涂成这种颜色即可,累加即可 #…
http://codeforces.com/contest/731/problem/F 注意到一个事实,如果你要找一段区间中(从小到大的),有多少个数是能整除左端点L的,就是[L, R]这样.那么,很明显,把这个区间分段.分成[L, 2 * L - 1],因为这段区间中,都不大于等于L的两倍,这样就使得这段区间的贡献就是sum_number * L了. 就是中间有多少个数,每个数贡献一个L值.然后到枚举[2 * L, 3 * L - 1]这段区间,贡献的值就是sum_number * (2 *…
题目链接:http://codeforces.com/contest/731/problem/F F. Video Cards time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Vlad is fond of popular computer game Bota-2. Recently, the developers…
题目链接: http://codeforces.com/contest/731/problem/A A. Night at the Museum time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Grigoriy, like the hero of one famous comedy film, found a job as a…
题目链接:http://codeforces.com/contest/731/problem/C 题解: 1.看题目时,大概知道,不同的袜子会因为要在同一天穿而差生了关联(或者叫相互制约), 其中一条袜子可以穿多次或者不穿.那么自然就想到用并查集(DSU), 把有关联的袜子放在一个集合(经过处理后,这个集合中所有的袜子的颜色一样). 2.集合问题搞定了,那么就轮到选颜色的为题了.怎么选颜色,使得每个集合的袜子颜色一样,且需要改变颜色的袜子尽可能少呢?方法是:对于每一个集合,选择袜子条数最多的那种…
A 模拟 #include <cstdio> #include <cstring> int Ans; ]; inline ?x:-x;} inline int Min(int x,int y) {return x>y?y:x;} int main() { ; scanf(); ;i<=strlen(Str+);i++) Ans+=Min(Abs(Str[i]-u),-Abs(Str[i]-u)),u=Str[i]; printf("%d\n",Ans…
在十五楼做的cf..一会一断...比赛的时候做出了ABCF 就没有时间了 之后没看题解写出了D..E是个神奇的博弈(递推或者dp?)看了题解也没有理解..先写了CDF.. C 有n个袜子 每个袜子都有颜色 给出m天穿的两只袜子编号 要求现在进行涂色 保证后m天每天的两只袜子都是一个颜色 可以想到和同一只袜子一起穿过的两只袜子 a == b && c == b 那就a == b 了 这样可以推出有关系的袜子都应该是一个颜色(连通分量) 由于要求出来最小涂多少只 那就bfs求一下连通分量大小…
F. Video Cards time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Vlad is fond of popular computer game Bota-2. Recently, the developers announced the new add-on named Bota-3. Of course…
C. Socks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prep…
A. Night at the Museum time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night…
题目链接: http://codeforces.com/contest/712/problem/E 题目大意: 一条直线上有n格,在第i格有pi的可能性向右走一格,1-pi的可能性向左走一格,有2中操作:单点修改pi以及询问从L格出发最终从R格离开区间[L,R]的概率. 这题在cf上A的人比较少,本来不打算去做的,然后看了下是概率的题目,比较感兴趣,就去做了下,然后发现并不会做,就搜了题解. 题解: 参考http://www.cnblogs.com/qscqesze/p/5868047.html…
题目链接: http://codeforces.com/contest/703/problem/D D. Mishka and Interesting sum time limit per test 3.5 secondsmemory limit per test 256 megabytes 问题描述 Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to prese…
http://codeforces.com/contest/447/problem/E 题意: 给定一个数组, m次操作, 1 l r 表示区间修改, 每次 a[i] +  Fibonacci[i-l+] 2 l r 区间求和 每次修改操作,只需要记录 每个点前两个值就可以了, 后面的和以及孩子需要加的值都可以通过这两个求出来. 推推公式就出来了. 注意 溢出. #include <bits/stdc++.h> using namespace std; typedef long long LL…
B. Preparing for the Contest 题目连接: http://codeforces.com/contest/377/problem/B Description Soon there will be held the world's largest programming contest, but the testing system still has m bugs. The contest organizer, a well-known university, has n…
D. Zip-line 题目连接: http://www.codeforces.com/contest/650/problem/D Description Vasya has decided to build a zip-line on trees of a nearby forest. He wants the line to be as long as possible but he doesn't remember exactly the heights of all trees in t…
D. Water Tree time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either…
D. The Child and Sequence time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of…
Codeforces Round #491 (Div. 2) https://codeforces.com/contest/991 A #include<bits/stdc++.h> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define IT set<ll>::iterator #define sqr(x) ((x)*(x)) #define pb…
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate it n = int(raw_input()) s = "" a = ["I hate that ","I love that ", "I hate it","I love it"] for i in ran…
Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/output 1 s, 256 MB    x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB    x1462 C Vasya and String standard input/output 1 s, 256 MB    x1393…
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输出”#Color”,如果只有”G”,”B”,”W”就输出”#Black&White”. #include <cstdio> #include <cstring> using namespace std; const int maxn = 200; const int INF =…
 cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....       其实这个应该是昨天就写完的,不过没时间了,就留到了今天.. 地址:http://codeforces.com/contest/651/problem/A A. Joysticks time limit per test 1 second memory limit per test 256…
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard in…
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his info…
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Victor adores the sets theory. Let us remind you that a set is a group of…
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给出的01序列相等(比较时如果长度不等各自用0补齐) 题解: 1.我的做法是用Trie数来存储,先将所有数用0补齐成长度为18位,然后就是Trie的操作了. 2.官方题解中更好的做法是,直接将每个数的十进制表示中的奇数改成1,偶数改成0,比如12345,然后把它看成二进制数10101,还原成十进制是2…