Skip to content

Instantly share code, notes, and snippets.

View chengluyu's full-sized avatar

Luyu Cheng chengluyu

View GitHub Profile
#include <iostream>
#include <cstdio>
using namespace std;
#define CONCAT(a, b) a##b
#define file_type CONCAT(FI, LE)
#define file_open CONCAT(fo, pen)
#define file_scanf CONCAT(fs, canf)
#include <iostream>
#include <cstdio>
using namespace std;
#define CONCAT(a, b) a##b
#define file_type CONCAT(FI, LE)
#define file_open CONCAT(fo, pen)
#define file_scanf CONCAT(fs, canf)
@chengluyu
chengluyu / gist:6219214
Created August 13, 2013 08:56
蛇形矩阵
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
const int MAX = 102;
const int STEP[4][2] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};
int matrix[MAX][MAX] = {0};
int n, x, y, s = 0, sum = 0;
@chengluyu
chengluyu / gist:6219251
Last active December 21, 2015 00:19
Calculator
#include <iostream>
#include <stdexcept>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;
class parse_error : exception {
string msg;
public:
parse_error(const char * str) : msg(str) { }
@chengluyu
chengluyu / gist:6262131
Last active December 21, 2015 06:09
A well-framed integral value to std::string function.
template <typename integral>
std::string to_string(integral value, int base = 10, bool lower_case = true) {
const char * digit = lower_case ? "0123456789abcedfghijklmnopqrstuvwxyz"
: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
assert(2 <= base && base <= 36);
std::string str;
bool negative = false;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Threading;
using System.Xml;
namespace Microsoft.MicrosoftMath
{
internal struct UInteger : IComparable<UInteger>, IEquatable<UInteger>
@chengluyu
chengluyu / multi-key-sort.cc
Last active December 24, 2015 15:39
Multi-key sort
// Type definition
class Object {
public:
int key1, key2, key3, key4;
};
// Comparator
bool comparator(const Object & lhs, const Object & rhs) {
if (lhs.key1 == rhs.key1) {
if (lhs.key2 == rhs.key2) {
\documentclass{ctexart}
\usepackage[margin=1.5cm]{geometry}
\usepackage{CJK}
\usepackage{verbatim}
\DeclareMathSizes{12}{20}{14}{10}
\title {东营市第一中学信息学信息学奥赛第一次模拟赛题解}
\author {作者:做好事不留名}
\begin{document}
\maketitle
作者说:我只是来练习\LaTeX 排版系统的。
@chengluyu
chengluyu / disjset.cpp
Created November 5, 2013 07:23
Disjoint Set
#include <iostream>
using namespace std;
const int N = 5000 + 1;
int n, m, q, pre[N], rank[N] = { 0 };
int get_father(int x) {
if (pre[x] == x)
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
const int N = 100000;
inline double square(double x) {