Skip to content

Instantly share code, notes, and snippets.

@whatalnk
whatalnk / monty.py
Created May 19, 2020
Monty Hall Problem
View monty.py
import argparse
from random import random
from fractions import Fraction
def monty(change=True):
right = 1
x = random()
if x <= Fraction(1 / 3):
answer = 1
@whatalnk
whatalnk / convertToKey.rb
Created Dec 10, 2019
find Windows Product Key
View convertToKey.rb
require 'win32ole'
# original vbscript is:
# https://support.lenovo.com/mx/ja/solutions/ht500032
#
def convertToKey(key)
keyOffset = 52
i = 28
chars = "BCDFGHJKMPQRTVWXY2346789"
keyOutput = ""
@whatalnk
whatalnk / abc100-b.cpp
Created May 17, 2019
AtCoder ABC #100 B - Ringo's Favorite Numbers
View abc100-b.cpp
#include <iostream>
using namespace std;
static int D, N;
int solve();
int ndiv(int x);
int ndiv(int x) {
@whatalnk
whatalnk / abc100-a.cpp
Created May 17, 2019
AtCoder ABC #100 A - Happy Birthday!
View abc100-a.cpp
#include <iostream>
using namespace std;
static int A, B;
void solve();
void solve() {
if (A <= 8 && B <= 8) {
@whatalnk
whatalnk / abc099-d.cpp
Created May 16, 2019
AtCoder ABC #099 D - Good Grid
View abc099-d.cpp
#include <iostream>
using namespace std;
const int MAX_C = 30;
static int N, C;
static int D[MAX_C][MAX_C];
static int t[3][MAX_C];
int solve();
@whatalnk
whatalnk / Makefile
Created May 15, 2019
Makefile for clang++ (AtCoder C++14 / Clang 3.8)
View Makefile
CXX = clang++-3.9
INCDIR = -I /usr/include/c++/v1 -I /home/linuxbrew/.linuxbrew/opt/boost@1.60/include
CFLAGS = -O2
LIBS = -L /usr/lib -L /home/linuxbrew/.linuxbrew/opt/boost@1.60/lib
OBJS = a.out
STD = c++14
STDLIB = libc++
WARNS = -Werror -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic
a.out: hello.cpp
@whatalnk
whatalnk / abc099-c.cpp
Created May 15, 2019
AtCoder ABC #099 C - Strange Bank
View abc099-c.cpp
#include <iostream>
using namespace std;
static int n;
int solve();
int solve() {
int ans = n;
for (int i = 0; i <= n; i++) {
@whatalnk
whatalnk / abc099-b.cpp
Created May 15, 2019
AtCoder ABC #099 B - Stone Monument
View abc099-b.cpp
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
static int a, b;
int solve();
@whatalnk
whatalnk / abc099-a.cpp
Last active May 15, 2019
AtCoder ABC #099 A - ABD
View abc099-a.cpp
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int n;
@whatalnk
whatalnk / agc033-a.cpp
Created May 14, 2019
AtCoder AGC #033 A - Darker and Darker
View agc033-a.cpp
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
const int MAX_H = 1000;
const int MAX_W = 1000;
You can’t perform that action at this time.