Skip to content

Instantly share code, notes, and snippets.

View henrybear327's full-sized avatar

Chun-Hung Tseng henrybear327

View GitHub Profile
@henrybear327
henrybear327 / Google IO 2012.md
Created April 30, 2018 06:40 — forked from jdh747/Google IO 2012.md
Go Concurrency Patterns: Google IO 2012

Concurrency Patterns in Go

Notes taken from Rob Pike's presentation 'Google I/O 2012 - Go Concurrency Patterns'.

1. Generator: function that returns a channel

The code is as follows:

c := boring("boring!")  // function returning a channel

for i := 0; i < 5; i++ {
@henrybear327
henrybear327 / main.cpp
Created April 21, 2018 15:40
Hypercube路徑
#include <bits/stdc++.h>
using namespace std;
void solve(int n)
{
int dp[1 << n];
memset(dp, 0, sizeof(dp));
int w[1 << n];
@henrybear327
henrybear327 / main.cpp
Last active April 21, 2018 15:12
GD5: Scheduling on many machines
#include <bits/stdc++.h>
using namespace std;
void solve()
{
int n, m;
scanf("%d %d", &n, &m);
priority_queue<int, vector<int>, greater<int>> pq;
@henrybear327
henrybear327 / 4.17.18 課綱.md
Last active July 6, 2018 02:18
4.17.18 課綱
  1. next_permutation() (sorting!)
  2. DFS
class Solution
{
private:
    vector<int> tmp;
 void dfs(vector &amp;nums, bool used[], vector&gt; &amp;ans,
@henrybear327
henrybear327 / uva10003.cpp
Created April 10, 2018 13:16
uva10003.cpp
#include <bits/stdc++.h>
using namespace std;
int dp[55][55];
int dfs(int inp[], int n, int l, int r) // (l, r)
{
if (r - l <= 1)
return 0;
if (dp[l][r] != -1)
@henrybear327
henrybear327 / dp_pathdomin.cpp
Created April 3, 2018 11:05
dp_pathdomin.cpp
#include <bits/stdc++.h>
using namespace std;
int solve(int n)
{
int dp[n][3];
int inp[n];
for (int i = 0; i < n; i++) {
@henrybear327
henrybear327 / total_distance.cpp
Created April 2, 2018 02:02
total_distance.cpp
#include <bits/stdc++.h>
using namespace std;
void solve()
{
int n;
scanf("%d", &n);
int par[n + 1], w[n + 1], deg[n + 1], cnt[n + 1];
@henrybear327
henrybear327 / DP_indepTree.cpp
Created March 16, 2018 17:44
Throwing a Party
#include <bits/stdc++.h>
using namespace std;
struct Data {
int p;
int w;
};
typedef pair<int, int> ii;
@henrybear327
henrybear327 / simulation_x^y.c
Created March 9, 2018 03:02
simulation_x^y.c
#include <stdio.h>
void solve()
{
long long int x, y, p;
scanf("%lld %lld %lld", &x, &y, &p);
long long int ans = 1;
while (y > 0) {
if (y & 1) {
@henrybear327
henrybear327 / simulation_Binary.c
Created March 9, 2018 02:56
simulation_Binary.c
#include <stdio.h>
#include <string.h>
void solve(int n)
{
long long int ans = 0;
for (int i = 0; i < n; i++) {
char inp[100];
scanf("%s", inp);
int len = strlen(inp);