Codechef Nuclear Reactors 题解】的更多相关文章

There are K nuclear reactor chambers labelled from 0 to K-1. Particles are bombarded onto chamber 0. The particles keep collecting in the chamber 0. However if at any time, there are more than N particles in a chamber, a reaction will cause 1 particl…
找一个数组中两数之间最小的不同值. 思路: 1 排序 2 后前相减,比較得到最小不同值 三个数甚至很多其它数之间的不同值都是这么求了,时间效率都是O(nlgn) -- 排序使用的时间 原题: http://www.codechef.com/problems/HORSES 笔者的练习文件非常大,所以还是使用类好,能够降低变量名和函数名的冲突. namespace有时候也不好用. #include <cstdio> #include <algorithm> #include <a…
Arranging Cup-cakes Our Chef is catering for a big corporate office party and is busy preparing different mouth watering dishes. The host has insisted that he serves his delicious cupcakes for dessert. On the day of the party, the Chef was over-seein…
Input t – the number of numbers in list, then t lines follow [t <= 10^6].  Each line contains one integer: N [0 <= N <= 10^6] Output Output given numbers in non decreasing order. Example Input: 5 5 3 6 7 1 Output: 1 3 5 6 7 大数据的排序,输入和输出. 一開始使用了co…
Chapter 1: Building Abstractions with Procedures 2015-09-29 016 Preface of this chapter QUOTE: The acts of the mind, where in it exerts its power over simple ideas, are chiefly these three ...... (John Locke, An Essay Concerning Human Understanding).…
China's appetite for coal, once seemingly unlimited, is starting to wane, and the effects are rippling far from the Middle Kingdom. wane:衰落,退潮,衰减 ripple:波纹,涟漪 With the world's second-largest economy, China in recent years has been driving demand for…
题意: 给出一棵含有\(n(1 \leq n \leq 10^5)\)个节点的树,每个顶点只有两种颜色:黑色和白色. 一开始所有的点都是黑色,下面有两种共\(m(1 \leq n \leq 10^5)\)次操作: \(0 \, u\)表示查询\(u\)所在的连通块的大小,相邻两个点颜色相同则属于一个连通块. \(0 \, u\)表示翻转\(u\)的颜色,即黑点变白点,白点变黑点. 分析: 参考CodeChef上的题解 首先将这棵树剖分成轻重链. 然后我们维护两个值:\(White(u)\)和\(…
http://www.codechef.com/NOV13 还在比...我先放一部分题解吧... Uncle Johny 排序一遍 struct node{ int val; int pos; }a[MAXN]; int cmp(node a,node b){ return a.val < b.val; } int main(){ int T,n,m; while(cin>>T){ while(T--){ cin>>n; ; i < n ; i++){ cin>&…
找出一个数组中的三个数,三个数不能组成三角形. 三个数不能组成三角形的条件是:a + b < c 两边和小于第三边. 这个问题属于三个数的组合问题了.暴力法可解,可是时间效率就是O(n*n*n)了,非常慢. 只是既然是组合问题就必然能够使用排序后处理的方法减少时间效率的. 这里减少时间效率的方法是: 选一个最大的数c.然后选两个小数a和b,当中a < b,假设符合条件,那么两个数中间的数必然都能够作为b符合条件a + b < c 这样能够把时间效率降到O(n*n). 这个规律也不好找啊.…
比赛链接:https://www.codechef.com/FEB18,题面和提交记录是公开的,这里就不再贴了 Chef And His Characters 模拟题 Chef And The Patents 模拟题 Permutation and Palindrome 模拟题 Car-pal Tunnel 结论比较简单 Broken Clock 求余弦的n倍角,可以用复数的快速幂解决 $cos(a)=x \\ sin(a)=\sqrt{1-x^2} \\ cos(na) = Re((x+\sq…