View insertionSort.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
void printVector(vector<int> A) { | |
for (int i = 0; i < A.size() - 1; ++i) { | |
cout << A[i] << " "; | |
} | |
cout << A.back() << endl; |
View warshall_floyd.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int MAX_V = (int)200; | |
int d[MAX_V][MAX_V]; // d[u][v]は辺(u,v)のコスト。0-origin. 初期化忘れずに | |
int V; | |
void warshall_floyd() { | |
REP(k, V) | |
REP(i, V) | |
REP(j, V) d[i][j] = min(d[i][j], d[i][k] + d[k][j]); | |
} |
View dijkstra.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int MAX_V = (int)1e5; | |
struct edge { | |
int to, cost; | |
}; | |
typedef pair<int,int> P; // 最短距離、頂点番号 | |
int V; // 頂点数 | |
vector<edge> G[MAX_V]; // グラフ i -> .to by .cost | |
int d[MAX_V]; // s からの最短距離。0-origin に注意 |
View procon.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
#define int long long | |
#define FOR(i, a, b) for (int i = (a); i < (b); ++i) | |
#define DEC(i, a, b) for (int i = (a); i > (b); --i) | |
#define REP(i, n) for (int i = 0; i < (n); ++i) | |
#define pb push_back | |
#define ALL(obj) (obj).begin(), (obj).end() | |
#define debug(x) cerr << #x << ": " << x << '\n' | |
using namespace std; | |
typedef long long ll; |
View gauss-jordan.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
void printmatrix(double a[10][11], int n) { | |
for (int i = 0; i < n; ++i) { | |
for (int j = 0; j < n+1; ++j) { | |
cout << a[i][j] << " "; | |
} | |
cout << endl; | |
} |
View MC.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main() { | |
int seed; | |
seed = 1533627; | |
srand48(seed); | |
double x, y, z; | |
int cnt; | |
int n = 10000; |
View drand48.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main() { | |
int i, seed; | |
double r; | |
seed = 1533627; | |
srand48(seed); | |
for (i = 0; i < 5; ++i) { | |
r = drand48(); |
View goudouhou.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int irand(int ir) { | |
int a = 5, c = 1, m = 16; | |
return (a * ir + c) % m; | |
} | |
int main() { | |
int r = 0; |
View kumiawase-no-kazu.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
int a = 2, b = 3, c = 8; //何通りか事前に計算しておく。 e.g. 2^3=8 | |
for (int i = 0; i < c; i++) { | |
for (int j = 0; j < b; j++) { | |
if((i/(1 << j))%a == 0) cout << "0"; | |
else cout << "1"; //if分岐はaの値に応じて増える | |
} |
View zundoko.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
"use strict"; | |
let arr = []; | |
for (let i = 0; i < 1e10; ++i) { | |
if (Math.random() < 0.5) { | |
arr.push(0); | |
console.log("ズン"); | |
} else { | |
arr.push(1); | |
console.log("ドコ"); |