A. Johny Likes Numbers time limit per test 0.5 seconds memory limit per test 256 megabytes input standard input output standard output Johny likes numbers n and k very much. Now Johny wants to find the smallest integer x greater than n, so it is divi…
题目链接:B.New Theatre Square 题意: 你要把所有"." 都变成"*",你可以有两个选择,第一种就是一次铺一个方块(1*1),第二种就是同一行一次铺两个(1*2).第一种花费x,第二种花费y.问最少花费多少能把所有铺完 题解: 如果y>=2*x,那么就直接找到所有".",然后乘于x就行 否则就找俩俩一对就行了 代码: 1 #include<stdio.h> 2 #include<algorithm>…
题目链接:E.Modular Stability 题意: 给你一个n数,一个k,在1,2,3...n里挑选k个数,使得对于任意非负整数x,对于这k个数的任何排列顺序,然后用x对这个排列一次取模,如果最后取模结果不变,那么称它为稳定的,求稳定数组的个数. 题解: 我们知道y%x%y!=y%y%x,那么如果要想满足题意那么这个最后的结果应该是0,也就是说这n个数里面那一个最小的x,这个x可以把剩下k-1个数整除,这样的话结果就肯定是0 比如如果k=3,n=10,那么(2,4,6,8,10),我们只需…
  C. Bracket Sequences Concatenation Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A bracket sequence is a string containing only characters "(" and ")". A regular…
TAT 第一场codeforces B. Array Walk #暴力 #贪心 题目链接 题意 有\(a1, a2, ..., an\) 个格子(每个格子有各自分数),最初为1号格(初始分数为\(a1\)),支持两种走法(经过的格子分数会相应累加),只能走\(k\)步:①向右走.②向左走,但是每一次向左操作走完一格后不能再连续地向左移动,允许向左走的操作次数为\(z\).现要求你走完k次后获得的最大分数. 分析 参考了官方题解,假定我们有\(t\)次移动是向左的,那么剩下\(k-t\)次向右,我…
题意: 给你一个含n个数a1,a2...an的数组,你要找到一个区间[l,r],使得al+a(l+1)+...+a(r-1)+ar减去max(al,a(l+1),...,a(r-1),ar)的值尽可能大 n<=1e5 -30<=ai<=30 题解: 因为ai的范围特别小,我们可以枚举区间[l,r]的最大值,然后就是暴力循环(这一点看代码) 代码: #include<stdio.h> #include<algorithm> #include<iostream&…
http://codeforces.com/contest/678/problem/D D. Iterated Linear Function Consider a linear function f(x) = Ax + B. Let's define g(0)(x) = x and g(n)(x) = f(g(n - 1)(x)) for n > 0. For the given integer values A, B, nand x find the value of g(n)(x) mod…
题目链接:http://codeforces.com/problemset/problem/678/D 简单的矩阵快速幂模版题 矩阵是这样的: #include <bits/stdc++.h> using namespace std; typedef __int64 LL; struct data { LL mat[][]; }; LL mod = 1e9 + ; data operator *(data a , data b) { data res; ; i <= ; ++i) { ;…
E. Another Sith Tournament 题目连接: http://www.codeforces.com/contest/678/problem/E Description The rules of Sith Tournament are well known to everyone. n Sith take part in the Tournament. The Tournament starts with the random choice of two Sith who wil…
D. Iterated Linear Function 题目连接: http://www.codeforces.com/contest/678/problem/D Description Consider a linear function f(x) = Ax + B. Let's define g(0)(x) = x and g(n)(x) = f(g(n - 1)(x)) for n > 0. For the given integer values A, B, n and x find t…
C. Joty and Chocolate 题目连接: http://www.codeforces.com/contest/678/problem/C Description Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern. An unpainted tile should be painted R…
B. The Same Calendar 题目连接: http://www.codeforces.com/contest/678/problem/B Description The girl Taylor has a beautiful calendar for the year y. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday,…
A. Johny Likes Numbers 题目连接: http://www.codeforces.com/contest/678/problem/A Description Johny likes numbers n and k very much. Now Johny wants to find the smallest integer x greater than n, so it is divisible by the number k. Input The only line con…
http://codeforces.com/contest/678 A:水题 #include<bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back #define pi acos(-1.0) #define ll long long #define mod 1000000007 #define C 0.5772156649 #define ls l,m,rt<…
Description Johny likes numbers n and k very much. Now Johny wants to find the smallest integer x greater than n, so it is divisible by the number k. Input The only line contains two integers n and k (1 ≤ n, k ≤ 109). Output Print the smallest intege…
题目链接: 题目 E. Another Sith Tournament time limit per test2.5 seconds memory limit per test256 megabytes inputstandard input outputstandard output 问题描述 The rules of Sith Tournament are well known to everyone. n Sith take part in the Tournament. The Tour…
Description Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern. An unpainted tile should be painted Red if it's index is divisible by a and an unpainted tile should be painted B…
Description The girl Taylor has a beautiful calendar for the year y. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday. The calendar is so beautiful that she wants to know wh…
  D. Iterated Linear Function time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Consider a linear function f(x) = Ax + B. Let's define g(0)(x) = x and g(n)(x) = f(g(n - 1)(x)) for n > 0. For…
D. Iterated Linear Function time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Consider a linear function f(x) = Ax + B. Let's define g(0)(x) = x and g(n)(x) = f(g(n - 1)(x))for n > 0. For the…
Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进行一次翻转,问是否存在一种方案,可以使得翻转后字符串的字典序可以变小.   这个很简单,贪心下就行了. 代码如下: Code #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 3e5…
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 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(…
Educational Codeforces Round 58 (Rated for Div. 2)  题目总链接:https://codeforces.com/contest/1101 A. Minimum Integer 题意: 多组数据,给你三个数l,r,d,要求在区间[l,r]之外找一个最小的x,使得x%d==0. 题解: 当d<l or d>r的时候,直接输出d就好了. 当l<=d<=r的时候,找到最小的t,使得t*d>r就行了. 具体操作见代码: #include…
人生第二场codeforces.然而遇上了Education场这种东西 Educational Codeforces Round 40 下午先在家里睡了波觉,起来离开场还有10分钟. 但是突然想起来还没报名呢,并且电脑又是开机黑屏什么情况 莫非为之后的凉凉埋下了伏笔? 比赛之前联系了下余翱和叶可禾,似乎都要去切题的样子? 想到第一次有人一起打CF还是有点小激动的.于是果断屏蔽余翱QQ上的刷屏去看A题了. A. Diagonal Walking 非常仔细地把题读了一遍,然后……啥这不是字符串入门题…
Educational Codeforces Round 69 (Rated for Div. 2) E. Culture Code 题目链接 题意: 给出\(n\)个俄罗斯套娃,每个套娃都有一个\(in_i,out_i\),并满足\(out_i>in_i\).定义套娃\(i\)能套在套娃\(j\)里面,当且仅当\(out_i\leq in_j\). 定义极大套娃组:当且仅当不能有另外一个套娃套在它们身上. 定义套娃组额外空间为\(in_1+(in_2-out_1)+\cdots +(in_k-…
Educational Codeforces Round 65 (Rated for Div. 2)题解 题目链接 A. Telephone Number 水题,代码如下: Code #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2e5 + 5; int a[N] ; int n, T; char s[N] ; int main() { cin >> T; whil…
Educational Codeforces Round 64 (Rated for Div. 2)题解 题目链接 A. Inscribed Figures 水题,但是坑了很多人.需要注意以下就是正方形.圆以及三角形的情况,它们在上面的顶点是重合的. 其余的参照样例判断一下就好了了.具体证明我也不会 代码如下: Code #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2e5 +…
Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ​ 初始\([1,500000]\)都为0,后续有两种操作: ​ \(1\).将\(a[x]\)的值加上\(y\). ​ \(2\).求所有满足\(i\ mod\ x=y\)的\(a[i]\)的和. [Solution] ​ 具体做法就是,对于前\(\sqrt{500000}=708\)个数,定义\(…
Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序 [Problem Description] ​ 给你一个有向图,给用最少的颜色给每条边染色,要保证不存在一个环中的所有边都是同一个颜色. [Solution] ​ 用拓扑排序判断图中是否存在环,若图中不存在环,则所有边都是同一种颜色.否则,同一个环中,只要用两种颜色就可以满足题目条件,所以总的颜色数就是两种,对于一个环,一定会存在两种边:1.节点号小…
UPD:变色了!!!历史最高1618~ Educational Codeforces Round 81 (Rated for Div. 2) The 2019 University of Jordan Collegiate Programming Contest   充实的一天,打两场可还行.补的一些题记录一下. edu81 Educational Codeforces Round 81 (Rated for Div. 2) 还不知道上分还是掉分,还挺可惜的,被B卡了没做出来,C也调了一会儿答案…