Skip to content

Instantly share code, notes, and snippets.

@kik
kik / gist:1363664
Created November 14, 2011 10:12
TPPmark7
Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq div choice fintype.
Require Import finfun path bigop.
Section Sec.
Parameter n : nat.
Parameter m : nat -> nat -> nat.
Parameter mmax : nat -> nat.
Parameter mmin : nat -> nat.
Parameter right : nat -> nat.
@kik
kik / gist:1366791
Created November 15, 2011 11:00
TPPmark7 その2
Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq div choice fintype.
Require Import finfun path fingraph bigop.
Section Sec.
Parameter ch : finType.
Parameter m : ch -> nat -> nat.
Parameter right : ch -> ch.
Parameter chpos : #|ch| > 0.
Parameter meven0 : forall c, odd (m c 0) = false.
@kik
kik / gist:1373247
Created November 17, 2011 14:23
sqrt 2
Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq div fintype.
Require Import finfun path prime.
Theorem s2irr : forall n m, 2 * n ^ 2 = m ^ 2 -> n = 0 /\ m = 0.
Proof.
move=> n m H.
have: ~~((n > 0) && (m > 0)).
apply/negP; case/andP => H1 H2.
move/(congr1 (fun x => odd (logn 2 x))): H.
by rewrite !logn_mul //= ?addnn ?odd_double ?expn_gt0 ?H1.
@kik
kik / A.v
Created April 15, 2012 10:30
GCJ 2012 Qual A
Require Import Ascii String List Sorting Permutation PermutEq PermutSetoid.
Open Scope char_scope.
Definition trans := ascii -> ascii.
Definition chars : list ascii :=
Eval compute in map ascii_of_nat (seq 0 256).
Definition smalls : list ascii :=
@kik
kik / B.cc
Created April 15, 2012 10:39
GCJ 2012 Qual B
#include <iostream>
using namespace std;
int main()
{
int T;
cin >> T;
for (int cas = 1; cas <= T; cas++) {
int N, S, p;
@kik
kik / C.cc
Created April 15, 2012 10:41
GCJ 2012 Qual C
#include <iostream>
#include <set>
using namespace std;
int main()
{
int T;
cin >> T;
for (int cas = 1; cas <= T; cas++) {
@kik
kik / D.cc
Created April 15, 2012 10:48
GCJ 2012 Qual D
#include <iostream>
#include <vector>
#include <boost/math/common_factor.hpp>
#include <algorithm>
using namespace std;
typedef vector<vector<char> > room_t;
int main()
@kik
kik / gist:2782177
Created May 24, 2012 15:19
cipher0x
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
@kik
kik / gist:2937189
Created June 15, 2012 15:51
Arduinoかんたん
int sc_rst = 2;
byte read_rst() {
return digitalRead(sc_rst);
}
void setup() {
Serial.begin(9600);
pinMode(sc_rst, INPUT);
while (read_rst())
@kik
kik / gist:6209891
Created August 12, 2013 10:55
ICFPC 2013 最終コード
#include <unistd.h>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>
#include <string>
#include <random>
#include <memory>