Skip to content

Instantly share code, notes, and snippets.

View chengluyu's full-sized avatar
😁
Working on a new project...

Luyu Cheng chengluyu

😁
Working on a new project...
View GitHub Profile
@chengluyu
chengluyu / main.md
Last active August 29, 2015 14:05
Problems to solve.
@chengluyu
chengluyu / tyvj1124.cpp
Created August 1, 2014 09:34
tyvj1124
/*
Problem: Tyvj 1124
Author: Cheng Luyu
Date: 2014/8/1 pm
*/
#include <cstdio>
#include <cstdlib>
const int N = 100, M = 100;
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
const int N = 100000;
inline double square(double x) {
@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)
\documentclass{ctexart}
\usepackage[margin=1.5cm]{geometry}
\usepackage{CJK}
\usepackage{verbatim}
\DeclareMathSizes{12}{20}{14}{10}
\title {东营市第一中学信息学信息学奥赛第一次模拟赛题解}
\author {作者:做好事不留名}
\begin{document}
\maketitle
作者说:我只是来练习\LaTeX 排版系统的。
@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) {
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 / 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;
@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) { }