cf B. Mishka and trip (数学)】的更多相关文章

题目链接: B. Mishka and trip time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, s…
题意   Mishka想要去一个国家旅行,这个国家共有个城市,城市通过道路形成一个环,即第i个城市和第个城市之间有一条道路,此外城市和之间有一条道路.这个城市中有个首中心城市,中心城市与每个城市(除了自己)之间有一条道路.第城市个城市有一个魅力值,经过一条连接第个和第个城市的道路的费用是,求所有道路的费用之和是多少?   注意:任何两个城市之间最多只有一条路. 思路   先考虑所有中心城市:每条路只能算一遍,那么我们可以得到如下公式:   其中,代表所有城市的魅力值的和,代表已经计算过的中心城市…
F - Mishka and trip Sample Output   Hint In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can…
Mishka and trip 题意: 有n个城市,第i个城市与第i+1个城市相连,他们边的权值等于i的美丽度*i+1的美丽度,有k个首都城市,一个首都城市与每个城市都相连,求所有边的权值. 题解: 先把n个城市存下来,之后开一个标记数组,来标记k个首都(这题这块很巧妙,正因为开了标记首都的数组,所以才把O(N^2)的算法降到了O(N)) 把所有城市的美丽值都加起来,遍历首都,每次遍历完就sum-首都,这样,最后求环的剩下的边就好了,环的剩下的边就是i不是首都,i+1也不是首都,那么就i*i+1…
B. Mishka and trip time limit per test 1 second memory limit per test 256 megabytes input  standard input output  standard output  Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she…
B. Mishka and trip time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she cho…
Description Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country. Here are some interesting facts about XXX: XXX consists of n …
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output   Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautifu…
[链接]:CF/4892 [题意]: 一个人解决n个问题,这个问题的值比k小, 每次只能解决最左边的或者最右边的问题 解决了就消失了.问这个人能解决多少个问题. [代码]: #include<bits/stdc++.h> #define PI acos(-1.0) #define pb push_back #define F first #define S second #define debug puts #define setp cout << fixed << s…
[链接]:CF [题意]:对于一个数n,每次加一的代价是a,每次减一的代价是b,求被m整除时的最小代价. [分析]:分情况讨论,自己多举几个栗子. [代码]: #include<cstdio> #include<string> #include<cstdlib> #include<cmath> #include<iostream> #include<cstring> #include<set> #include<qu…