Skip to content

Instantly share code, notes, and snippets.

View qnighy's full-sized avatar

Masaki Hara qnighy

View GitHub Profile
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
public class Wave extends JFrame {
int w = 50;
int h = 50;
double[][] height;
double[][] speed;
class Array
def flatten(dep=-1,ary=[])
each{|i|Array===i&&dep!=0?i.flatten(dep-1,ary):ary<<i}
ary
end
end
p [[1],[[2]],3,[4]].flatten(-1)
p [[1],[[2]],3,[4]].flatten(0)
p [[1],[[2]],3,[4]].flatten(1)
p [[1],[[2]],3,[4]].flatten(2)
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int main(int argc, char **argv) {
for(int kk = 1; ; kk++) {
int marbs[7];
int sum = 0;
for(int i = 1; i <= 6; i++) {
#include <cstdio>
#include <cstring>
using namespace std;
int dp[7][60001];
int main(int argc, char **argv) {
for(int k = 1; ; k++) {
int sum = 0;
memset(dp, -1, sizeof(dp));
dp[0][0]=0;
#include <iostream>
using namespace std;
class Sora {
const char *name;
int num;
public:
Sora() : name("ソラ"), num(0) {}
const Sora& operator--() {num++;return *this;}
const Sora& operator++() {num++;return *this;}
@qnighy
qnighy / sin.c
Created April 9, 2010 11:48
print sine curve without sin() function
#include <stdio.h>
int main(void) {
double s=0,c=1;
int i,j;
for(i = 0; i < 100; i++) {
double ns=(s*60+c*11)/61;
double nc=(c*60-s*11)/61;
for(j = 0; j < ns*30+30; j++) {
putchar(' ');
}
@qnighy
qnighy / 1811.cpp
Created April 11, 2010 06:20
POJ 1811 using Quantum Sieve
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47,
53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191,
#include "json.h"
static QVariant readJSONArray(QTextStream &in);
static QVariant readJSONObject(QTextStream &in);
inline int fromHexChar(int ch) {
return (ch<='9') ? ch-'0' : (ch<='Z') ? ch+(10-'A') : ch+(10-'a');
}
static QString readJSONString(QTextStream &in) {
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
int getat(const vector<int> &a, int x) {
return (x<0||x>=(int)a.size()) ? 0 : a[x];
}
int &getrat(vector<int> &a, int x) {
@qnighy
qnighy / c.cpp
Created June 5, 2010 16:48
なんだこのGCJ2010 Round 2 C-large。あってるかしらん
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
struct Rect {
int x1,y1,x2,y2;
};