题目链接:https://codeforces.com/contest/1700/problem/B#include<iostream> #include <string.h> #include<string> #include <cmath> #include <algorithm> using namespace std; int main(){ int u; cin>>u; for(int i=1;i<=u;i++) {int...
https://codeforces.com/contest/1516/problem/B Baby Ehab is known for his love for a certain operation. He has an arrayaa of lengthnn, and he decided to keep doing the following operation on it: he picks22 adjacent elements; he then removes them and places a single integer in their plac...
https://codeforces.com/problemset/problem/525/E 每个仙女有三种情况,枚举一下,n对半分,使得复杂度变成o(k*3^(n/2)) 用map统计的时候,每次如果跑for的话会有很多重复的,这样可以直接存下来前缀和 for(auto i:mp){for(intj=1;j<=25;j++){ mp[i.first][j]+=mp[i.first][j-1]; } } 1. 2...
https://codeforces.com/contest/1301/problem/B #include https://codeforces.com/contest/1301/problem/B 如果填的这个数特别大,显然不优,如果数特别小,也不优,所以它是凸函数,可以二分(整数单峰函数二分模板题 #include <iostream>#include<cstdio>#include<queue>#include<algorithm>#include<cmath>#include<...
https://codeforces.com/problemset/problem/525/E 每个仙女有三种情况,枚举一下,n对半分,使得复杂度变成o(k*3^(n/2)) 用map统计的时候,每次如果跑for的话会有很多重复的,这样可以直接存下来前缀和 for(auto i:mp){for(intj=1;j<=25;j++){ ...
https://codeforces.com/problemset/problem/1304/E 用lca求树上距离 只有3种情况 a->b a->x+x->y+y->b a->y+y->x+x->b 因为距离过长就可以来回走,所以k-len得是偶数 #include <iostream>#include<cstdio>#include<cstdlib>#include<algorithm>#include<cmath>#include<cstring>#defineinf 21474836...
https://codeforces.com/problemset/problem/1304/E 用lca求树上距离 只有3种情况 a->b a->x+x->y+y->b a->y+y->x+x->b 因为距离过长就可以来回走,所以k-len得是偶数 #include <iostream>#include<cstdio>#include<cstdlib>#include<algorithm>#include<cmath>#include<cstring>#defineinf 21474836...
E. Ehab's REAL Number Theory Problem数论+图论 求最小环 题目大意: 给你一个n大小的数列,数列里的每一个元素满足以下要求: 数据范围是:1<=ai<=1061<=ai<=106 aiai最多只有7个因数 题目要求在这个数列找到一个最短的子数列,子数列的所有的数相乘是一个完全平方数。
题目链接:https://codeforces.com/contest/1999/problem/D #include<iostream> #include<string> #include <vector> using namespace std; int ma