rmq.cpp
: RMQ implementation.poj_3264.cpp
: 3264 -- Balanced Lineuppoj_1769.cpp
: 1769 -- Minimizing maximizerpoj_3171.cpp
: 3171 -- Cleaning Shifts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dot_product(p, q, o = None): | |
""" | |
Calculate a dot product of two vectors(tuples) p and q. | |
If the vector o is given, use it as an origin. | |
>>> dot_product((), ()) | |
0 | |
>>> dot_product((2,), (3,)) | |
6 | |
>>> dot_product((3,), (4,), (1,)) | |
6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def in_delta(p, q, delta): | |
""" | |
Returns True if p and q are of the same length and | |
the elements at the same index of each are | |
approximately equal within the error delta. | |
>>> in_delta([], [], 0) | |
True | |
>>> in_delta([1], [1], 1.0e-10) | |
True | |
>>> in_delta([1], [1.01], 1.0e-10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 0-1 Knapsack Problem Random Sample Generation. | |
#include <iostream> | |
#include <sstream> | |
#include <vector> | |
#include <string> | |
#include <iterator> | |
#include <algorithm> | |
#include <ctime> | |
#include <cstdlib> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iterator> | |
#include <string> | |
#include <sstream> | |
#include <vector> | |
#include <algorithm> | |
#include <cassert> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
using namespace std; | |
template <typename T> | |
struct rmq_tree { | |
int n; | |
T inf; | |
vector<T> v; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo 'This script will create a temporary directory in ~/tmp.' | |
exit 1 # Remove this line to run this script. | |
set -x | |
DIR=`mktemp -d -p ~/tmp/` | |
mkdir -p $DIR/bare |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bindata' | |
require 'pp' | |
class VarString < BinData::Record | |
uint8 :size_bytes # Length of data (in bytes). | |
string :data, length: :size_bytes | |
end | |
class Child < BinData::Record | |
# See bindata/lazy.rb: when evaluating lambdas, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To compile (using VC): | |
// cl main.c /link gdi32.lib user32.lib kernel32.lib | |
#include <tchar.h> | |
#include <math.h> | |
#include <windows.h> | |
TCHAR *szWindowClass =_T("Window Class Name"); | |
#define PI 3.14159265 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>My first processing.js sample</title> | |
<script type="text/javascript" src="processing.js"></script> | |
</head> | |
<body> | |
<h1>Sample: Dragging the ball</h1> | |
<script type="application/processing" src="test.processing"></script><canvas></canvas> | |
<br/> | |
Useless:) |
OlderNewer