摘要: import java.math.*;import java.util.*;import java.io.*;public class Main { public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); BigInteger sum = BigInteger.valueOf(0); BigInteger curr; while ( cin.hasNext() ) ... 阅读全文
posted @ 2013-05-02 00:58 Sinker 阅读(116) 评论(0) 推荐(0) 编辑
摘要: import java.util.concurrent.*;import java.util.*;public class Deadlock { public static void main(String[] args) { ExecutorService executor = Executors.newCachedThreadPool(); executor.execute(new R()); executor.execute(new W()); executor.shutdown(); } p... 阅读全文
posted @ 2013-04-20 20:10 Sinker 阅读(153) 评论(0) 推荐(0) 编辑
摘要: import java.util.concurrent.*;import java.util.*;public class WriterFirst { public static void main(String[] args) { ExecutorService executor = Executors.newCachedThreadPool(); executor.execute(new Reader()); executor.execute(new Writer()); executor.shutdown(); }... 阅读全文
posted @ 2013-04-20 19:58 Sinker 阅读(352) 评论(0) 推荐(0) 编辑
摘要: import java.util.concurrent.*;import java.util.*;public class ReaderFirst { public static void main(String[] args) { ExecutorService executor = Executors.newCachedThreadPool(); executor.execute(new Reader()); executor.execute(new Writer()); executor.shutdown(); ... 阅读全文
posted @ 2013-04-20 19:39 Sinker 阅读(269) 评论(0) 推荐(0) 编辑
摘要: import java.util.concurrent.*;import java.util.*;public class ConsumerProducer { public static void main(String[] args) { ExecutorService executor = Executors.newCachedThreadPool(); executor.execute(new Consumer()); executor.execute(new Producer()); executor.shutdow... 阅读全文
posted @ 2013-04-16 23:28 Sinker 阅读(346) 评论(0) 推荐(0) 编辑
摘要: Inmathematics, therearrangement inequality[1]states thatfor every choice ofreal numbersand everypermutationofx1, ...,xn. If the numbers are different, meaning thatthen the lower bound is attained only for the permutation which reverses the order, i.e. σ(i)=n−i+1 for alli= 1,...,n, and the upper boun 阅读全文
posted @ 2013-04-14 00:53 Sinker 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 彩笔的发现:(1)动态trie超时。(2)要保证OJ输入的原子性,不可中途随意break掉。(3)memset过大的数组也挺耗时的。#include <stdio.h>#include <string.h>#define BRANCH 1#define LEAF 0const int MAXN = 10;const int MAXLEN = 20;const int NIL = 0;typedef struct { int type; int count; int next[MAXN];}NODE;int root;NODE trie[1000000];int cnt; 阅读全文
posted @ 2013-04-06 13:44 Sinker 阅读(130) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <string.h>#include <stdlib.h>#define BRANCH 1#define LEAF 0const int MAXN = 256;const int MAXLEN = 10000;typedef struct NODE { int type; int count; struct NODE* next[MAXN];}NODE;NODE root;char buffer[MAXLEN];int pos;void INSERT(const char* s){ NODE* curr; 阅读全文
posted @ 2013-04-06 02:01 Sinker 阅读(122) 评论(0) 推荐(0) 编辑
摘要: //past for (int i = 0; i < N - 1; i++) printf("%d ", a[i]); printf("%d\n", a[N - 1]); //now for (int i = 0; i < N; i++) printf("%d%c", a[i], (i < N - 1) ? ' ' : '\n');the latterone is apparently more elegent than the former one in manifestation, 阅读全文
posted @ 2013-04-03 00:19 Sinker 阅读(109) 评论(0) 推荐(0) 编辑
摘要: Jeff Dean , a famous Google engineer, popularized a list of latency numbers everyone should know. The list is a great resource for designing large scale infrastructure systems.Algorithms and their complexity often occur in critical parts of computer systems, but I find that few engineers have a good 阅读全文
posted @ 2013-04-01 21:08 Sinker 阅读(186) 评论(0) 推荐(0) 编辑