codeforce好地方啊 Bear and Elections *】的更多相关文章

Codeforces Round #318 居然可以看测试数据,哪里没过一目了然,哈哈哈 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<map> using namespace std; #define MOD 1000000007 cons…
                                                A. Bear and Elections                                                                                                                                                                            time limi…
A. Bear and Elections time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Limak is a grizzly bear who desires power and adoration. He wants to win in upcoming elections and rule over the Bearla…
优先队列模拟一下就好. #include<bits/stdc++.h> using namespace std; priority_queue<int>q; int main() { int n; scanf("%d",&n); int t; scanf("%d",&t); ; i <= n; i++){ int v; scanf("%d",&v); q.push(v); } ; while(…
题目链接   A. Currency System in Geraldion 有1时,所有大于等于1的数都可由1组成.没有1时,最小不幸的数就是1. #include<iostream> #include<cstdio> #include<algorithm> using namespace std; void solve(){ int n,x; scanf("%d",&n); ; ; i<=n; i++){ scanf("%…
以后每做完一场CF,解题报告都写在一起吧   暴力||二分 A - Bear and Elections 题意:有n个候选人,第一个候选人可以贿赂其他人拿到他们的票,问最少要贿赂多少张票第一个人才能赢 分析:正解竟然是暴力!没敢写暴力,卡了很久,导致这场比赛差点爆零!二分的话可以优化,但对于这题来说好像不需要... 收获:以后CF div2的A题果断暴力   代码(暴力): /************************************************ * Author :R…
Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob. Right now, Limak and Bob weigh a and b respectively. It's guaranteed that Limak's weight is smaller than or equal to his brother's weight. Limak eats…
/* 题意就是要找到包含“bear”的子串,计算出个数,需要注意的地方就是不要计算重复. */ 1 #include <stdio.h> #include <string.h> #include <stdlib.h> #define maxn 5005 char str[maxn]; int pos[maxn]; int main() { while(~scanf("%s",str)) { ; memset(pos, , sizeof(int));…
385D - Bear and Floodlight 题目大意:有一个人从( l , 0 ) 想走到 ( r , 0 ),有 n 盏路灯,位置为( xi , yi ),每盏路灯都有一个照射的角度ai 这个角度内的区间都被照亮,问你走之前任意调路灯的方向,这个人只能走路灯照亮的地方,问你他最多能往 r 方向走多少距离. 思路:本来我想的是才20盏灯直接枚举灯的顺序也不会超时的吧,复杂度才20!* 20 (ps:我错了我是猪,20!复杂度很高), 结果GG,T掉了,改成状态压缩就过了,状态压缩也跑了…
D. Bear and Chase 题目连接: http://codeforces.com/contest/679/problem/D Description Bearland has n cities, numbered 1 through n. There are m bidirectional roads. The i-th road connects two distinct cities ai and bi. No two roads connect the same pair of…
B. Bear and Finding Criminals 题目连接: http://www.codeforces.com/contest/680/problem/B Description There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|. Limak…
C. Bear and String Distance 题目连接: http://www.codeforces.com/contest/628/problem/C Description Limak is a little polar bear. He likes nice strings - strings of length n, consisting of lowercase English letters only. The distance between two letters is…
Valera and Elections 题意:现在有n个候选人, 有n-1条路, 如果选择了这个候选人, 这个候选人就会将从自己这个城市到1号城市上所有坏的路都修复一下,现在求最小的候选人数目, 如果答案有多种情况输出任何一种都可以. 输入:x y k 表示x与y之间有一条双向通道, k==1 表示这路是好的, k == 2表示这条路是坏的. 题解: 从1开始dfs搜索, 往外走, 如果遇到坏的城市就标记一下, 然后继续往外走, 如果更远的地方有一个坏的路就用更远地方的城市候选人代替这个标记的…
Bear and Polynomials 题解: 如果改变一个其中的一个数,那么需要知道的是,前面的数都可以进到当前位来,如果过不来的话,那么就会因为前面有数导致无法变成0. 所以我们将前面的数不断向高位转移,找到第一个不能往上进位的位置, p. 现在只有在0 <= i <= p 的时候才有解. 然后我们从高位到地位转移系数. 然后到0 <= i <= p的地方再check合法性. 注意的是,如果当前系数的绝对值  > 2e9, 那么就是不会再出现合法情况了, 因为不可能再变…
Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of hi identical blocks. For clarification see picture for the first sample. Limak will repeat the following o…
In the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize a demonstration at one of th…
1.VS2008在Windows7 打开维护界面看不到可以输序列号的地方. 因为微软把他隐藏了. 2.我们可以借用工具把他显示出来 下载地址:http://www.zlsoft.com/techbbs/UploadFile/2010-7/2010716148883786.rar 3.使用方法 打开工具,填入你的找到序列号,点击开启,打开控制面板,调出VS2008的维护界面,点击下一步,提示升级成功.…
介绍 GCC(Google Closure Compiler)是由谷歌发布的Js代码压缩编译工具.它可以做到分析Js的代码,移除不需要的代码(dead code),并且去重写它,最后再进行压缩. 三种压缩模式 GCC提供三种压缩模式: 1)Whitespace only 2)Simple 3)Advanced 我们以这段简单的代码为例 function sayHello(name) { alert('Hello, ' + name); } sayHello('binnng'); 分别使用这三种压…
eclipse项目上面有个红叉,但是没有任何地方有错误,clear,refresh,重启都试过了,依然没用, 后来我换了一个workspace,编译的时候提示: Description Resource Path Location Type The project was not built due to "Could not delete ' 意思是编译的文件删不掉,因为要重新编译嘛, 然后找度娘,才知道,我eclipse刚才关闭方式错误,导致进程没关,kill掉进程,clear一下,ok;…
F. Bear and Fair Set time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Limak is a grizzly bear. He is big and dreadful. You were chilling in the forest when you suddenly met him. It's very u…
C. Bear and String Distance time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Limak is a little polar bear. He likes nice strings - strings of length n, consisting of lowercase English letter…
前言 近期杂事甚多,这些事情的积累对知识体系的提升有好处,但是却不能整理出来,也整理不出来 比如说我最近研究的Hybrid在线联调方案便过于依赖于业务,就算分享也不会有人读懂,若是抽一点来分享又意义不大 又拿最近做webapp view 转场动画研究,就是几个demo不断测试,感觉没有什么可说的 最后甚至对webapp中的History的处理方案也是有一些心得,一点方案,但是依旧难以整理成文,于是便开始文荒了 这个时候不妨便温故知新吧,对javascript的一些老知识点进行整理回顾,之后有大动…
思路:重写ListView的setOnTouchListener事件: ListView.setOnTouchListener(new OnTouchListener(){ @Override public boolean onTouch(View arg0, MotionEvent arg1) { // TODO Auto-generated method stub hideMenu();//隐藏菜单 return false; } }); 延申: 点击窗体空白地方隐藏菜单或软键盘思路一样:…
package com.beiwo.inputstream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class lianxi { /** * @param args * 练习题: 将一张图片拷贝到另外一个地方. * @throws IOException */ public static void main(String[] args)…
校区的周围有很多的网吧,一个对电子游戏迷恋了许久的青少年来说,那绝对是不可不去的地方,键盘,鼠标,显示器,那一切看起来都那么完美,那么似曾相识,是啊,魂牵梦绕的IT梦...哦..当时那只是电子游戏梦.. 就这样我理所当然的办理了学校周围十几个网吧的会员,练就了一身午夜12点从宿舍翻四道墙,五分钟到达网吧包宿一身本领. 更理所当然的 大学报考志愿的时候,我只有专科可以报了,我那时候想,算了去上个北大青鸟吧...好歹我还会用电脑..玩游戏.. 没想到我还是被一个专科的计算机专业录取了.. 第一次接触…
const的可变性 const用于声明常量. 什么是常量,声明后的值不可更改. 对于值类型,比如string,number等等.const声明确实有效. const str = "string"; str = 1; // Uncaught TypeError: Assignment to constant variable. 对于引用类型,比如array,object.const声明只保证了引用不可更改,但保证不了其内容. const arr = []; arr.push(1); //…
[原文链接] 采用锚点进行页面中的跳转的确很方便,但是要想增加网页的效果,可以使用jquery中的animate,实现滚动的一个动作,慢慢的滚动到你想跳转到的位置,从而看起来会非常高大上. [示例演示地址] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <…
参考资料:http://cn.mathworks.com/help/matlab/ref/fread.html 注意:参考资料针对的Matlab版本号R2015a,我使用的是R2013b. Matlab帮助文件中给出了这几种用法 A = fread(fileID) A = fread(fileID,sizeA) A = fread(fileID,sizeA,precision) A = fread(fileID,sizeA,precision,skip) A = fread(fileID,siz…
感谢rulary的指正!博文中我对IOCP的理解是有误的,正确的方式请见评论区rulary的回复! 由于项目实际设计的需要,最终IO事件处理没有采用IOCP,而是采用了NT6.0引入的WSAPoll,其编程模型和linux下poll基本一致,此处就不赘述了! ==================================================   IOCP是windows下IO事件处理的最高效的一种方式了,结合OVERLAPPED IO可以实现真正的完全异步IO.windows在…
下面的内容主要来源于<Thinging in Java> 这本书的第22页讲到的,有5个不同的地方可以存储数据: 1).寄存器 这是最快的存储区,因为它位于处理器内部(没错,如果学过计算机组成原理的同学应该知道这个比较接近于cpu),但是寄存器的数量极其有限,所以寄存器根据需求进行分配.你不能直接控制,也不能在程序中感觉到寄存器的存在的任何迹象. 2).堆栈(通常也简称栈内存) 位于通用RAM(随机访问存储器)中,但通过堆栈指针可以从处理器那里获得直接支持.堆栈指针若向下移动,则分配新的内存.…