This file contains hidden or 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
/* | |
* A fast exponentiation. | |
* The algo has O(log(m)) time complexity, additionally it gets a boost because of compile time. | |
*/ | |
template <int n, int mod, int debug_info, int m> | |
struct fast_exp { | |
static constexpr int value = (m % 2 == 0) ? fast_exp<(n * n) % mod, mod, debug_info, m / 2>::value : (n * fast_exp<(n * n) % mod, mod, debug_info, (m - 1) / 2>::value) % mod; | |
static constexpr void run_debug() { | |
static_assert(value == debug_info, "failed"); |
This file contains hidden or 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> | |
#include <cmath> | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
int size; | |
std::cin >> size; |
This file contains hidden or 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
rm -rf *.o *.bin *.img | |
nasm -f bin bootsect.asm -o bootsect.bin | |
gcc -ffreestanding -c main.c -o main.o | |
gcc -c video.c -o video.o | |
gcc -c ports.c -o ports.o | |
ld -e main -Ttext 0x1000 -o kernel.o main.o video.o ports.o | |
ld -i -e main -Ttext 0x1000 -o kernel.o main.o video.o ports.o | |
objcopy -R .note -R .comment -S -O binary kernel.o kernel.bin | |
./makeboot a.img bootsect.bin kernel.bin |
This file contains hidden or 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
[BITS 16] ; We need 16-bit intructions for Real mode | |
[ORG 0x7C00] ; The BIOS loads the boot sector into memory location 0x7C00 | |
;jmp word load | |
global _start | |
jmp _start | |
drive db 0 | |
; jmp reset_drive | |
; jmp enter_pm |
This file contains hidden or 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
void backtrack(int* a, int k, int n) | |
{ | |
if (k == n) | |
{ | |
for(int i = 1; i <=k; ++i) | |
{ | |
if (a[i] == true) | |
{ | |
std::cout << i << " "; | |
} |
This file contains hidden or 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 <vector> | |
double vagner_fisher_sed_algo(const std::string& s, | |
const std::string& d) | |
{ | |
std::vector<std::vector<double> > t(s.length() + 1, | |
std::vector<double>(d.length() + 1)); | |
t[0][0] = 0; | |
double o; |
This file contains hidden or 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 <limits.h> | |
#include <stdlib.h> | |
#include <queue> | |
struct node | |
{ | |
int d; | |
int w; |
This file contains hidden or 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> | |
class heap | |
{ | |
private: | |
int size; | |
private: | |
int get_left(int i); | |
int get_rigth(int i); |
This file contains hidden or 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> | |
int main() | |
{ | |
int a[8]; | |
const char c = 'a'; | |
for(unsigned int i = 0; i < sizeof(char)*8; ++i) | |
{ | |
if(c & (1 << i)) |
NewerOlder