GYM - 101620 J.Justified Jungle】的更多相关文章

题意: 给出一棵树,删掉其中一些边,要求生成的每个子树节点数一样.输出所有可以删掉的边数. 题解: 以节点1为根,预处理每个子树的大小.对于每个n的因数x,还需满足子树为他倍数的点够n/x个,那么删的边数就为n/x-1. #include <bits/stdc++.h> using namespace std; ; int n; int u, v; int sz[N], vis[N]; int tot; ], nxt[N<<]; vector<int> ans; voi…
 2017 JUST Programming Contest 2.0 题目链接:Codeforces gym 101343 J.Husam and the Broken Present 2 J. Husam and the Broken Present 2 time limit per test:1.0 s memory limit per test:256 MB input:standard input output:standard output After you helped Husam…
http://codeforces.com/gym/100240 J [分析] 这题我搞了好久才搞出样例的11.76....[期望没学好 然后好不容易弄成分数形式.然后我‘+’没打..[于是爆0... 好桑心.. 对于x^2这样的期望,是不能直接求x的期望然后平方的! 为什么呢?因为意义就是不对的,你的概率有可能乘了两次什么的... 我的方法是: 先把每天分离出来,对于某一天,假设你前i部番的x^2的期望求了出来,然后新的一部翻在这天放的概率是p, 新的答案就是$x^{2}*(1-p)+p*(x…
Codeforces GYM 100876 J - Buying roads 题解 才不是因为有了图床来测试一下呢,哼( 题意 给你\(N\)个点,\(M\)条带权边的无向图,选出\(K\)条边,使得得到的子图联通并且总代价最小,输出最小总代价和一种方案. 虽然题目里描述的很冗长,但其实这个图有一些性质:它最初是一条链/一个环,然后再有一些结点直接连到这些在链上/环上的结点.. 下图就是一个(就是样例): 做法 首先我们可以简单的查看点的度数来找到链/环上的点,和连接它们的边. 然后我们可以通过…
J. Deck Shuffling Time Limit: 2   Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/J Description The world famous scientist Innokentiy continues his innovative experiments with decks of cards. Now he has a deck of n cards and k…
题目链接: http://codeforces.com/gym/100114 Description The computer network of “Plunder & Flee Inc.” consists of n servers and m two-way communication links. Two servers can communicate either through a direct link, or through a chain of links, by relayi…
Problem J. Bye Bye RussiaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/attachments Description It was the last day at Russia, after the World Finals has ended. Coach fegla was travelling back to Cairo on the same day b…
J. Computer Network Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description The computer network of “Plunder & Flee Inc.” consists of n servers and m two-way communication links. Two servers can communicate either thr…
题目链接:http://codeforces.com/gym/100187/problem/J 题目链接:问通过洗牌器,能否将编号为x的牌子转移到第一个位置? 根据 洗牌器,我们可以知道原本在第i位置的牌可以转移到第j个位置,且这种转移是单向的.如果要把在某个位置的牌转移到第一个位置,那么必须至少存在一条转换路径,其起点为这张牌的位置,起终点为第一个位置.所以就很自然想到建图,然后用dfs跑一遍. 代码如下: #include<iostream> #include<cstdio>…
http://codeforces.com/gym/100801 题目大意:有从左到右有n个车站,有n-1种车票,第i种车票一次最多可以坐 i 站(1<=i<=n)   每种票有固定的价钱p[i],下车后可以继续上车,但每次下车都要再上车都要花费一定时间v[i],第1和n站上车不花费时间,车从一站到相邻的一站需要1分钟.只能买一种车票,问在t时间内 所有能从第1站到 第n站的方案  花费 的票价最低是多少. 解题思路: 这道题的关键在于如何求每种票起点到达终点所需的最少时间,如果找出了每种票到…