Avito Code Challenge 2018 A~E】的更多相关文章

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…
Portal A. Antipalindrome 暴力. B. Businessmen Problems 暴力. C. Useful Decomposition 居然不是C打头的?! 将一棵树划分成若干条边不相交的路径,使得任意两个路径均有交点. 易知树上的两条路径最多有一个交点.若有三条路径两两相交,则必形成三个交点或一个交点.设路径1与路径2交于\(v_1\),路径1与路径3交于\(v_2\),路径2与路径3交于\(v_3\).若\(v_1\neq v_2 \neq v_3\),则有路径\(…
再次作死的打了一次cf的修仙比赛感觉有点迷.. 还好掉的分不多(原本就太低没法掉了QAQ) 把会做的前三道水题记录在这.. A: Antipalindrome emmmm...直接暴力枚举 code: //By Menteur_Hxy #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> using namespace std; int n,ans; cha…
第一次打CF,很菜,A了三道水题,第四题好像是是数位DP,直接放弃了.rateing从初始的1500变成了1499,还是绿名,这就很尴尬.之后觉得后面的题目也没有想象的那么难(看通过人数)过两天吧剩下的五题给补上. http://codeforces.com/contest/981 A:给你一个字符串S,求把这个字符串中的最长不回文子序列. 思路: 如果S不回文,那就是本身 如果S回文: (1)如果S由一种字母构成,那么最长不回文子序列为空,因为无论删除多少个都是回文串. (2)如果S不是上述情…
C. Useful Decomposition time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)! He created a new us…
A. Antipalindrome 还以为是什么神dp结果就是分情况讨论啊 原串是一串一样的字符的话输出0,是回文串的话输出n-1,否则直接输出原串长度 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int N=55; int n; char s[N]; int main() { scanf("%s",s+1); n=strlen(s+…
题目链接:http://codeforces.com/contest/981/problem/G 题目大意: 有n个初始为空的‘魔法’可重集,向一个‘可重集’加入元素时,若该元素未出现过,则将其加入:否则该可重集中所有元素的个数都会翻倍. 例如将$2$加入${1,3}$会得到${1,2,3}$,将$2$加入${1,2,3,3}$会得到${1,1,2,2,3,3,3,3}$. $q$次操作,每次操作要么向一个区间内的所有可重集加入某个元素,要么询问一个区间内可重集的大小之和. $n,q ≤ 2×1…
传送门:http://codeforces.com/contest/1081/problem/E E. Missing Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Chouti is working on a strange math problem. There was a sequence of nn …
传送门:http://codeforces.com/contest/1081/problem/C C. Colorful Bricks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output On his free time, Chouti likes doing some housework. He has got one new…
传送门:http://codeforces.com/contest/1081/problem/B B. Farewell Party time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Chouti and his classmates are going to the university soon. To say goodbye…
考挂了.. A - Definite Game 直接看代码吧. #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<set> #include<map> #include<vector> #include<cmath> #include<cctype> using namespace std;…
A. Definite Game: 题意:输入N,输出最小的结果N-x,其中x不少N的因子. 思路:N=2时,输出2:其他情况输出1:因为N>2时,N-1不会是N的因子. #include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<=b;i++) using namespace std; ; int a[maxn]; int main() { int N; cin>>N; ) puts("); "…
A:n==2?2:1. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; #define ll long long ')) c=getchar();return c;} ?n:gcd(m,n%m);} int read() { ,…
A. Definite Game 签. #include <bits/stdc++.h> using namespace std; int main() { int a; while (scanf("%d", &a) != EOF) { [](int x) { ; i >= ; --i) if (x % i) { printf("%d\n", x - i); return; } printf("%d\n", x); }(…
题目链接 题意 : 给出一个联通图和一些特殊的点,现在定义cost(u,v)为一条从u到v的路径上面边权的最大值 , 定义dis(u,v) 为从u到v 路径上面cost 的最小值 然后求所有特殊点到其他特殊点的最大距离 题解: 做这题前,首先思考一件事情,对于一颗树来说点到点的距离是不是就是树上面路径的边权最大值 我们来证明一下:假设在最小生成树上面的路径cost为w1,另外在原图中还有一条路径从u到v,其cost为w2,那么必然有w2>w1的.那么我们最后的dis一定是w1. 那么我们现在的目…
A. Definite Game 题目链接:https://codeforces.com/contest/1081/problem/A 题意: 给出一个数v,然后让你可以重复多次减去一个数d,满足v%d!=0,问最后可以得到最小的是多少. 题解: 除开v=2输出2,其余直接输出1就行了= =/ 代码如下: #include <bits/stdc++.h> using namespace std; int main(){ int v; cin>>v; cout<<(v==…
D. Maximum Distance 题目链接:https://codeforces.com/contest/1081/problem/D 题意: 给出一个连通图以及一些特殊点,现在定义cost(u,v)为一条从u到v的路径上面边权的最大值,然后定义dis(u,v)为从u到v所有路径上面cost的最小值. 最后求所有特殊点到其它特殊点的最大距离... 题解:这个题意似乎有点绕... 我们考虑一下最小生成树,那么点与点之间的距离就为最小生成树路径上面边权的最大值. 我们来证明一下:假设在最小生成…
E. Missing Numbers 题目链接:https://codeforces.com/contest/1081/problem/E 题意: 现在有n个数(n为偶数),但只给出a2,a4....an的信息,要求你求出a1,a2....an. 假设前n项的和为Sn,那么满足S1,S2....Sn都为平方项. 题解: 假设S1=a^2,S2=b^2,S3=c^2,S4=d^2,因为我们已知a2,a4,所以得出a2=S2-S1=b^2-a^2,a4=d^2-c^2. 我们可以根据我们设的未知数推…
C. Colorful Bricks 题目链接:https://codeforces.com/contest/1081/problem/C 题意: 有n个横向方块,一共有m种颜色,然后有k个方块的颜色与其左边的颜色不同(第一个除外),问一共有多少染色方案. 题解: 我们首先来考虑一下dp. 设dp(i,j)为当前第i个方块,一共有j个方块与它前面的方块不同的方案个数. 那么转移方程为dp(i,j)=dp(i-1,j-1)*(m-1)+dp(i-1,j). 代码如下: #include <bits…
题目大意: 有n个人 接下来一行n个数a[i] 表示第i个人描述其他人有a[i]个的帽子跟他不一样 帽子编号为1~n 如果所有的描述都是正确的 输出possible 再输出一行b[i] 表示第i个人的帽子的编号 如果存在矛盾 输出impossible 如果存在p 个人都描述有q个人跟他们的帽子不一样 此时若 p+q=n 说明正确且这p个人的帽子都一样 如 a[] = 3 3 2 2 2 ,此时一种解为 b[] = 1 1 2 2 2 存在p=2个人描述有q=3个人跟他们不一样 说明这两个人的帽子…
题目大意: 1*n的格子 可以用m种颜色涂色 已知从第2开始到第n个格子 有k个格子与其左边的格子颜色不同 求涂色的方案数 相当于把n个格子分成k+1份 可以递推出分成k+1份的不同的方案数(其实递推公式就是组合数递推公式) 也可以隔板法直接求C(n-1,k) 已知所有分法后 直接涂色 那么第一份可以涂m种颜色 而第二块开始只能涂m-1种 因为要和左边那一份的颜色不同 所以C(n-1,k)*m*(m-1)^k 一定要注意取模问题 乘法要取模 递推时的加法也要取模啊 太粗心了 赛后递推加个取模就过…
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…
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…
这场比赛好毒瘤哇,看第四题好像是中国人出的,怕不是dllxl出的. 第四道什么鬼,互动题不说,花了四十五分钟看懂题目,都想砸电脑了.然后发现不会,互动题从来没做过. 不过这次新号上蓝名了(我才不告诉你我以前的号是灰名),还是挺高兴的,而且t神这场比赛又成第一了. 比赛传送门:http://codeforces.com/contest/1075 A. The King's Race 题意:有一黑一白两个旗子,白的在(1, 1)上,黑的在(n, n)上.每次可以将旗子移动到周围一圈这八个位置,给你三…
传送门 \(MAXEP\) 二分,不过二分的时候要注意把\(mid\)设成\(\left\lfloor{9l+r\over 10}\right\rfloor\),这样往右的次数不会超过\(6\)次 //minamoto #include<bits/stdc++.h> #define R register #define inline __inline__ __attribute__((always_inline)) #define fp(i,a,b) for(R int i=(a),I=(b)…
A. Broken Clock time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format…
比赛链接:https://www.codechef.com/FEB18,题面和提交记录是公开的,这里就不再贴了 Chef And His Characters 模拟题 Chef And The Patents 模拟题 Permutation and Palindrome 模拟题 Car-pal Tunnel 结论比较简单 Broken Clock 求余弦的n倍角,可以用复数的快速幂解决 $cos(a)=x \\ sin(a)=\sqrt{1-x^2} \\ cos(na) = Re((x+\sq…
B. Verse Pattern 题目连接: http://codeforces.com/contest/722/problem/B Description You are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters. We define a syllable as a string that c…
A. Broken Clock time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format…