http://codeforces.com/contest/1075/problem/A On a chessboard with a width of nn and a height of nn, rows are numbered from bottom to top from 11 to nn, columns are numbered from left to right from 11 to nn. Therefore, for each cell of the chessboard,…
这场比赛好毒瘤哇,看第四题好像是中国人出的,怕不是dllxl出的. 第四道什么鬼,互动题不说,花了四十五分钟看懂题目,都想砸电脑了.然后发现不会,互动题从来没做过. 不过这次新号上蓝名了(我才不告诉你我以前的号是灰名),还是挺高兴的,而且t神这场比赛又成第一了. 比赛传送门:http://codeforces.com/contest/1075 A. The King's Race 题意:有一黑一白两个旗子,白的在(1, 1)上,黑的在(n, n)上.每次可以将旗子移动到周围一圈这八个位置,给你三…
B. Taxi drivers and Lyft time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Palo Alto is an unusual city because it is an endless coordinate line. It is also known for the office of Lyft Level…
A---The King's Race http://codeforces.com/contest/1075/problem/A 题意: 一个人在\((1,1)\), 一个人在\((n,n)\), 现在他们每次轮流走一步,问谁先到达\((x,y)\) 思路: 每个人走到\((x,y)\)的步数是可以直接求出的. #include <bits/stdc++.h> #define inf 0x3f3f3f3f using namespace std; typedef long long LL; L…
A. The King's Race 签. #include <bits/stdc++.h> using namespace std; #define ll long long ll n, x, y; ll f(ll a, ll b) { return max(abs(a - x), abs(b - y)); } int main() { while (scanf("%lld%lld%lld", &n, &x, &y) != EOF) { puts(…
https://codeforces.com/contest/1075/problem/C 题意 一个宽为1e9*1e9的矩阵中的左下角,放置一个车(车可以移动到同一行或同一列),放置一些墙,竖的占据一列,横的有一的长度,问车从最下角走到第1e9行最少拆多少面墙? 思路 看了看数据范围以为是一道离散化的题,但是发现车可以往左走 然后再明确了一下题意,墙是永久拆去的,反应到可以优先拆竖着的墙,然后假如剩下横着的墙比竖着的墙少的话,可以直接拆横着的墙 写之前看了一下题意,说横着的墙不会有交点,然后大…
夜晚使人着迷.没有猝死非常感动. A:显然对于水平线段,只有横坐标的左端点为1的时候才可能对答案产生影响:对于竖直直线,如果要删一定是删去一段前缀.枚举竖直直线删到哪一条,记一下需要删几条水平线段就可以了.想当然的以为竖直直线横坐标是升序排的,因为这个wa了两发感觉非常惨. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring>…
题目链接:1033D - Divisors 题目大意:给定\(n\)个数\(a_i\),每个数的约数个数为3到5个,求\(\prod_{i=1}^{n}a_i\)的约数个数.其中\(1 \leq n \leq 500 , 1 \leq a_i \leq 2\cdot 10^{18}\). 题解:考虑约数个数公式,可以发现对于任意的\(a_i\),有\(a_i=\left\{\begin{matrix}p^2\\ p^3\\ p^4\\ p_1\cdot p_2\end{matrix}\right…
A. King Escape 签. #include <bits/stdc++.h> using namespace std; ], y[]; int f1(int X, int Y) { ] + y[]; } int f2(int X, int Y) { ] + y[] - X - Y; } bool ok() { //if (f1(x[0], y[0]) * f1(x[1], y[1]) < 0) return false; //if (f2(x[0], y[0]) * f2(x[1…
打猝死场感觉非常作死. A:判一下起点和终点是否在其两侧即可. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; int read() { ,f=;char c=getchar(); ;c=getchar();} )+(x<…
Yandex.Algorithm 2018, final round A Smart Vending B LIS vs. LDS C Eat And Walk D Search Engine E Guess Me If You Can 思路:如果n这个位置加1的话,不同的数的个数要么不变,要么加1,反之,如果不同的数的个数减少,肯定不是n这个位置加1 我们random_shuffle()50次,每次把不是n的位置标记一下,这样有很大的概率把所有的不是n的位置都标记了 代码: #pragma GC…
http://codeforces.com/contest/1075/problem/B Palo Alto is an unusual city because it is an endless coordinate line. It is also known for the office of Lyft Level 5. Lyft has become so popular so that it is now used by all mm taxi drivers in the city,…
The last stage of Football World Cup is played using the play-off system. There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the…
A.B都是暴力搞一搞. A: #include<bits/stdc++.h> #define fi first #define se second #define mk make_pair #define pii pair<int,int> #define read(x) scanf("%d",&x) #define sread(x) scanf("%s",x) #define dread(x) scanf("%lf&quo…
In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are n inflorescences, numbered from 1 to n. Inflorescence number 1 is situated near base of tree and any othe…
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error. Kirill has already made his measurements, and has got the following integer value…
Two friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the point x1 = a, another one is in the point x2 = b. Each of the friends can move by one along the line in any direction unlimited number of times. When…
1. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort    暴力枚举,水 1.题意:n*m的数组,每行最多可交换1次,列最多可交换两列,问最终是否可以变换到每行都是1~m. 2.总结:暴力即可. #include<bits/stdc++.h> #define F(i,a,b) for (int i=a;i<b;i++) #define FF(i,a,b) for (int i=a;i&l…
Codeforces Avito Code Challenge 2018 D. Bookshelves 题目连接: http://codeforces.com/contest/981/problem/D Description Mr Keks is a typical white-collar in Byteland. He has a bookshelf in his office with some books on it, each book has an integer positive…
题目列表:https://loj.ac/problems/search?keyword=JOI+2018+Final T1 寒冬暖炉 贪心 暴力考虑每相邻两个人之间的间隔,从小到大选取即可 #include<iostream> #include<string.h> #include<string> #include<stdio.h> #include<algorithm> #include<math.h> #include<ve…
2017 Russian Code Cup (RCC 17), Final Round A Set Theory 思路:原题转换一下就是找一个b数组,使得b数组任意两个数的差值都和a数组任意两个数的差值相等 根据题目数据范围, 肯定可以构造一个1, 1+d, 1+2d, 1+3d, ... , 1+(n-1)*d的序列 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits…
Codechef October Challenge 2018 游记 CHSERVE - Chef and Serves 题目大意: 乒乓球比赛中,双方每累计得两分就会交换一次发球权. 不过,大厨和小厨用了另外一种规则:双方每累计得 K 分才会交换发球权.比赛开始时,由大厨发球. 给定大厨和小厨的当前得分(分别记为 P1 和 P2),请求出接下来由谁发球. 思路: \((P1+P2)\%K\)判断奇偶性即可. 代码链接 BITOBYT - Byte to Bit 题目大意: 在字节国里有三类居民…
Codechef September Challenge 2018 游记 Magician versus Chef 题目大意: 有一排\(n(n\le10^5)\)个格子,一开始硬币在第\(x\)个格子里.\(m(m\le10^4)\)次操作,每次交换指定的两个格子.问最后硬币在第几个格子里. 思路: 按题意模拟即可. 源代码: #include<cstdio> #include<cctype> inline int getint() { register char ch; whi…
LOJ#2351. 「JOI 2018 Final」毒蛇越狱 https://loj.ac/problem/2351 分析: 首先有\(2^{|?|}\)的暴力非常好做. 观察到\(min(|1|,|0|,|?|)\le 6\),我们只需要推出一个\(2^{|0|}\)和\(2^{|1|}\)的容斥式子 而这个式子也是很好推的. 考虑子集反演: \(f(S)=\sum\limits_{T\subseteq S}g(T)\) \(g(S)=\sum\limits_{T\subseteq S}(-1…
 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 #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 #372 (Div. 2) C. Plus and Square Root 题意 一个游戏中,有一个数字\(x\),当前游戏等级为\(k\),有两种操作: '+'按钮:使得\(x=x+k\) '√'按钮:使得\(x=\sqrt{x}\),此时\(x\)必须是平方数,游戏等级加1,即\(k=k+1\),且\(\sqrt{x}\)是\(k+1\)的倍数. 游戏开始时,\(x=2,k=1\),输出\(n(n \le 10^5)\)个数,表示每个等级对应的\(\frac…
A. Sereja and Dima time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Sereja and Dima play a game. The rules of the game are very simple. The players have n cards in a row. Each card contains…
Codeforces Round #485 (Div. 2) E. Petr and Permutations 题目连接: http://codeforces.com/contest/987/problem/E Description Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to gene…
Codeforces Round #485 (Div. 2) C. Three displays 题目连接: http://codeforces.com/contest/987/problem/C Description It is the middle of 2018 and Maria Stepanovna, who lives outside Krasnokamensk (a town in Zabaikalsky region), wants to rent three displays…