1 2 3 4 5 6 7 4-5-3-6-2-7-1 答案是(n-1)/2 #include<cstdio> using namespace std; int n; int main(){ scanf("%d",&n); printf("%d\n",(n-1)/2); return 0; }…
C. Find Amir time limit per test   1 second memory limit per test   256 megabytes   A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends. There…
最后肯定是bbbb...aaaa...这样. 你每进行一系列替换操作,相当于把一个a移动到右侧. 会增加一些b的数量……然后你统计一下就行.式子很简单. 喵喵喵,我分段统计的,用了等比数列……感觉智障.一个a一个a地统计答案即可. #include<cstdio> #include<cstring> #include<iostream> using namespace std; #define MOD 1000000007ll typedef long long ll;…
A. Fake NP time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.…
题目大意:给出一个森林,每次询问给出u,v,问从u所在连通块中随机选出一个点与v所在连通块中随机选出一个点相连,连出的树的直径期望(不是树输出-1).(n,q<=10^5) 解法:预处理出各连通块的直径和各点到连通块内一点的最远距离d[x](树形dp+换根),询问若在同一块内输出-1,否则若随机选出两点x,y,直径为max(d[x]+d[y]+1,x所在块直径,y所在块直径),我们把同一连通块内的d排序,枚举小的连通块中的d,到大的连通块中二分d[x]+d[y]+1<=max(x所在块直径,y…
来自FallDream的博客,未经允许,请勿转载,谢谢. 由于人傻又菜 所以这次又滚去div2了  一堆结论题真的可怕 看见E题不是很有思路   然后就去大力搞F题  T了最后一个点 真的绝望   但是还是上紫了 感觉每次cf都在乱打 我好菜啊都不会 A.Fake NP 给定l和r,求[l,r]中的数的因数中出现次数最多的那一个 sb题 如果l和r相同输出它 不然输出2 #include<iostream> #include<cstdio> #include<cstring&…
D. Minimum number of steps time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of s…
A. Fake NP 题意:给你l,r,让你输出[l,r]里面除1以外的,出现因子数量最多的那个数. 题解:如果l==r输出l,否则都输出2 #include<bits/stdc++.h> using namespace std; int main(){ int l,r; cin>>l>>r; if(r-l==0){ cout<<l<<endl; return 0; } int ans = 0; int num = 0; for(int i=2;…
比赛时候切了A-E,fst了A Standings第一页只有三个人挂了A题,而我就是其中之一,真™开心啊蛤蛤蛤 A. Fake NP time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak…
对那个树进行dfs,在动态维护那个当前的冰激凌集合的时候,显然某种冰激凌仅会进出集合各一次(因为在树上形成连通块). 于是显然可以对当前的冰激凌集合贪心染色.暴力去维护即可.具体实现看代码.map不必要. #include<cstdio> #include<set> #include<vector> #include<map> #include<algorithm> using namespace std; map<int,bool>…