Hanh lives in a shared apartment. There are nn people (including Hanh) living there, each has a private fridge. nn fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The ow…
Long is a huge fan of CFC (Codeforces Fried Chicken). But the price of CFC is increasing, so he decides to breed the chicken on his own farm. His farm is presented by a rectangle grid with rr rows and cc columns. Some of these cells contain rice, oth…
Bob is an avid fan of the video game "League of Leesins", and today he celebrates as the League of Leesins World Championship comes to an end! The tournament consisted of nn (n≥5n≥5) teams around the world. Before the tournament starts, Bob has…
Bob watches TV every day. He always sets the volume of his TV to bb. However, today he is angry to find out someone has changed the volume to aa. Of course, Bob has a remote control that can change the volume. There are six buttons (−5,−2,−1,+1,+2,+5…
//题目要求的是每一个点最少要有两条边连接,所以可以先构成一个环.然后再把剩余的最短的边连接起来 #include<iostream> #include<algorithm> using namespace std ; ; int n,m; struct edge { int num; int w; } a[N]; int T; bool cmp(edge a,edge b) { return a.w<b.w; } void solve() { ; ; i<=n; i+…
Codeforces Round #601 (Div. 2) ---- 比赛传送门 周二晚因为身体不适鸽了,补题补题 A // http://codeforces.com/contest/1255/problem/A /* 签到题 简单的贪心题 本考虑过是否有先小于再加上去会更小的情况 但两种情况恰好步数是一样的 */ #include<iostream> #include<cstdio> #include<cmath> using namespace std; int…
传送门 A. Changing Volume 签到. Code /* * Author: heyuhhh * Created Time: 2019/11/19 22:37:33 */ #include <bits/stdc++.h> #define MP make_pair #define fi first #define se second #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define…
cf 上的一道好题:  首先发现能生成所有数字-N 判断奇偶 就行了,但想不出来,如何生成所有数字,解题报告 说是  所有数字的中最大的那个数/所有数字的最小公倍数,好像有道理:纪念纪念: #include<iostream> #include<stdio.h> #include<algorithm> #include<cstring> #include<algorithm> #include<cmath> using namespa…
D. Berland Fair time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output XXI Berland Annual Fair is coming really soon! Traditionally fair consists of nn booths, arranged in a circle. The booths ar…
Codeforces Round #601 (Div. 2) E2. Send Boxes to Alice (Hard Version) N个盒子,每个盒子有a[i]块巧克力,每次操作可以将盒子中的一块巧克力左移或右移,要求移动后的每个盒子中的巧克力数量都能被k整除(无视空盒子),求最小的操作数.(1<=N<=1e6,0<=a[i]<=1e6) 题解 k只需考虑巧克力总数的质因子 考虑每个盒子的贡献,盒子中可以保存k的整数倍(k*i)块巧克力,从左向右递推,每个盒子保留最大数目的…