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 <stack> | |
using std::cout; | |
using std::vector; | |
using std::stack; | |
vector<int> emigration(const vector<int>& average) | |
{ |
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 <string> | |
#include <algorithm> | |
#include <climits> | |
// Преобразование строки в число до первого неверного символа | |
int str_to_int(const std::string& str) | |
{ | |
auto end = str.end(); | |
// Пропускаем пробелы |
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 <algorithm> | |
using std::cout; | |
using std::vector; | |
template <typename T> | |
void shift_array(vector<T>& array, size_t value) | |
{ |
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 <string> | |
#include <vector> | |
// Factorial radix | |
namespace fact_radix | |
{ | |
// factorial digit type | |
using fact_digits = std::vector<int8_t>; | |
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> | |
using namespace std; | |
// Returns -1 for illegal source number (n) | |
int spec_sum(int n) | |
{ | |
if (n < 100 || n > 999) return -1; | |
int a = n/100, b = n/10%10, c = n%10; | |
if (b+c == 0) return n*2; |
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
# Find numbers of specified length that are complete squares with ascending sorted non-repeating digits in specified radix | |
# Returns list of found values of None on invalid radix or length parameters | |
def find_perfect_squares(radix, length): | |
if not 2 <= radix <= 36 or not 1 <= length < radix: | |
return None | |
from math import ceil, floor | |
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
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 <iomanip> | |
#include <array> | |
#include <algorithm> | |
#include <numeric> | |
#define SQUARE_SIZE 4 | |
//#define PRINT_SQUARES | |
#define DEBUG |
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 <fstream> | |
#include <string> | |
#include <unordered_map> | |
#include <algorithm> | |
#include <chrono> | |
using std::cout; | |
using std::cerr; | |
using std::cin; |
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 <string> | |
#include <vector> | |
#include <list> | |
using std::cout; | |
using std::cin; | |
using std::string; | |
using std::vector; | |
using std::list; |
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 <functional> | |
// Bracket balance search function, returns number of found balances | |
// count - number of brackets pairs | |
// callback - function called for found bracket balance (parameters: uint64_t - bracket balance bit mask, int - number of bracket pairs) | |
// bit balance: lower bit (number 0) - first bracket, higher bit (number count-1) - last bracket: 0 - opened, 1 - closed | |
// list - bracket balance bit mask (used in recursion, leave zero on root call) | |
// opened, closed - number of opened/closed brackets in list (used in recursion, leave zero on root call) | |
uint64_t brackets(int count, std::function<void(uint64_t, int)> callback, uint64_t list = 0, int opened = 0, int closed = 0) |