比赛时愣是没读懂
题意:有N 个城市 每个城市都有 val 个 士兵 , 有几条路连接
当敌方攻击你的某个城市时 该城市以及与该城市相连接的城市的士兵总数 要大于 K
不大于 K 该城市就被攻陷,士兵被俘虏 则不能支援别的城市
求最后一共有多少城市不被攻陷,以及士兵总数
思路:先计算该点能支援到的总士兵数
然后将 总数小于 K 的取出 减去相连的城市上的总士兵数
...
分类:
其他好文 时间:
2014-10-06 23:05:11
阅读次数:
267
非递归解法
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class...
分类:
其他好文 时间:
2014-10-06 12:54:00
阅读次数:
211
1.Python程序结构:输入-处理-输出输出语句:print()函数format格式化函数format(val,‘m.nf‘)m.nf,m是占位符,例如:print(format(12.243,‘3.2f‘))->_12.24
print(format(0.1245,‘2.2%‘))->12.45%输入语句:raw_input([promot])返回的是字符串re=raw_input()
type(re)-&..
分类:
编程语言 时间:
2014-10-06 02:19:11
阅读次数:
289
部长练习全选-取消-反选-显示选择内容等功能代码:
部长练习全选-取消-反选-显示选择内容等功能
$(document).ready(function(e) {
//实现全选功能
$(':input[value=全选]').click(function(){
//alert($(this).val());
$('for...
分类:
Web程序 时间:
2014-10-05 17:52:58
阅读次数:
196
我们都知道,堆是向到高地址扩展的,栈是向低地址扩展的,那么堆和栈的地址那个高呢?int _tmain(int argc, _TCHAR* argv[]){ int stack_val = 0; int* heap_ptr = new int(2); printf("stack ad...
分类:
其他好文 时间:
2014-10-04 22:33:17
阅读次数:
208
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
bool hasCycl...
分类:
其他好文 时间:
2014-10-04 15:09:06
阅读次数:
187
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Soluti...
分类:
其他好文 时间:
2014-10-04 15:07:46
阅读次数:
162
1. Type conversion:If we assign an out-of-range value to an object of unsigned type, the result is the remainder of the value modulo the number of val...
分类:
编程语言 时间:
2014-10-03 18:53:04
阅读次数:
198
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* Lis...
分类:
其他好文 时间:
2014-10-03 17:21:45
阅读次数:
167
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* ...
分类:
其他好文 时间:
2014-10-03 15:40:04
阅读次数:
186