Poj 3262 Protecting the Flowers

总计 153 字
原题地址 知识点:贪心 解题报告 #include <cstdio> #include <iostream> #include <algorithm> #include <vector> using namespace std; struct P { int t, d; }; // 贪心使得代价最小 // cost = 2 * T * (total - D) // 因此 D越大,T越小越好 // 重点:转换成

poj 1017 Packets

总计 317 字
知识点:贪心 解题报告 #include <cstdio> #include <algorithm> int square[7]; // 解法:每次都先放最大 int solve() { int res = 0; // 6x6 直接成一块 res += square[6]; // 5x5 先成一块,再补 1x1 res += square[5]; square[1] -= 11 * square[5]; // 4x4 先成一块,然

poj 3040 Allowance

总计 303 字
知识点: 贪心 解题报告 #include <cstdio> #include <iostream> #include <algorithm> #include <vector> #include <string.h> #include <limits> using namespace std; struct Coin { int d; int b; }; bool cmp(const Coin &a, const Coin &b) { return a.d > b.d; } vector<Coin> v; int N, C; int need_count[20]; int main() { scanf("%d %d", &N, &C); int res = 0; for(int i=0;i<N;i++) { struct Coin c;

poj 1979 Red and Black

总计 161 字
知识点:DFS solution #include <cstdio> int W, H; char tile[25][25]; int pos_x, pos_y; int sh_x[4] = {0, 0, -1, 1}; int sh_y[4] = {1, -1, 0, 0}; int res = 0; void solve(int x, int y) { tile[y][x] = '#'; res++; for (int i=0;i<4;i++) { int new_x = x + sh_x[i]; int new_y = y + sh_y[i]; if (new_x >= 0 && new_x <W &&

通过Go HTTP Client的报错看标准库https请求

Go
总计 2981 字
在用 Go 自带的 http client 进行默认 Get 操作的时候,发现如下错误 x509: certificate signed by unknown authority 这个报错来自 crypto/x509 中关于证书签名的验证 负责验证证书的方法签名 func (c *Certificate) Verify(opts VerifyOptions) (chains [][]*Certificate, err error) 关于

AC之路 序

总计 298 字
不知不觉就要到大三了,也玩过很多东西,但总感觉缺乏新的挑战,到达了一个瓶颈。 于是想要隐居深山,闭关修炼,回到计算机的本源,更多跟深地去死磕自

LeetCode题解:最长回文串之manacher算法

总计 733 字
manacher 俗称马拉车算法,也是本文的主角,是一种能够将最长回文串的求解复杂度降低到 O(N) 的一种高效算法, 当我第一次见到求解最长回文串的题目时,首先采用的

无缓冲通道引发的BUG

Go
总计 540 字
最近在刚玩具级的 MapReduce ,其中充斥着大量的并发编程的代码,稍有不慎就可能导致 Map 或者 Reduce 的时候遭遇到未知的阻塞状态 (Blocking),导致整个系统无

分布式初探 Distributed 101

总计 1228 字
什么是分布式系统? 使用多机来处理单机相同问题的系统 多点存储,多点计算 为什么需要分布式系统? 解决日益增长的存储资源和计算资源占用的问题,分散系

0交换排序 Google笔试题

总计 202 字
题目: 长度为n的数组乱序存放着0至n-1,现在只能进行0与其他数的交换,请排序这个数组 package main import "fmt" func main() { s := []int{3, 5, 4, 0, 1, 2, 6} for _, v := range s { fmt.Printf("%d ", v) }