Skip to content

Instantly share code, notes, and snippets.

View mhmoodlan's full-sized avatar

Mahmoud Aslan mhmoodlan

View GitHub Profile
@mhmoodlan
mhmoodlan / hc-sr04-with-buzzer.ino
Created October 16, 2020 21:10
Arduino script to measure average distance using HC-SR04 ultrasonic sensor and buzzing as the distance gets less than a threshold (10cm) with increasing frequency as the distance gets shorter.
#define echoPin 7
#define trigPin 8
long duration;
long distance;
int n = 0;
double accumulator = 0.0;
void setup() {
Serial.begin(9600);
@mhmoodlan
mhmoodlan / 10865 - Brownie Points.cpp
Created November 30, 2017 09:29
#Geometry #UVa #Solved
//https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1806
#include <bits/stdc++.h>
#define ll long long
#define sz(v) ((int) ((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define lp(i, n) for(int i = 0; i < (int)(n); ++i)
#define rep(i, v) for(int i = 0; i < sz(v); ++i)
using namespace std;
@mhmoodlan
mhmoodlan / C. Barcode.cpp
Created October 8, 2017 13:39
#DP #PickOrLeave #Matrices #Codeforces #Solved
//http://codeforces.com/contest/225/problem/C
#include <bits/stdc++.h>
#define ll long long
#define sz(v) ((int) ((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define lp(i, n) for(int i = 0; i < (int)(n); ++i)
#define rep(i, v) for(int i = 0; i < sz(v); ++i)
using namespace std;
@mhmoodlan
mhmoodlan / C. Divisibility by Eight.cpp
Created October 7, 2017 17:14
#DP #Math #DivisibleBy8 #BruteForce #Solved #Codeforces
//http://codeforces.com/contest/550/problem/C
#include <bits/stdc++.h>
#define ll long long
#define sz(v) ((int) ((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define lp(i, n) for(int i = 0; i < (int)(n); ++i)
#define rep(i, v) for(int i = 0; i < sz(v); ++i)
using namespace std;
@mhmoodlan
mhmoodlan / C. Woodcutters.cpp
Created October 7, 2017 11:09
#DP #PickOrLeave #Codeforces #Solved
//http://codeforces.com/contest/545/problem/C
#include <bits/stdc++.h>
#define ll long long
#define sz(v) ((int) ((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define lp(i, n) for(int i = 0; i < (int)(n); ++i)
#define rep(i, v) for(int i = 0; i < sz(v); ++i)
using namespace std;
@mhmoodlan
mhmoodlan / A. Juicer.cpp
Created October 6, 2017 07:59
#Implementation #Easy #Codeforces #Solved
//http://codeforces.com/contest/709/problem/A
#include <bits/stdc++.h>
#define ll long long
#define sz(v) ((int) ((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define lp(i, n) for(int i = 0; i < (int)(n); ++i)
#define rep(i, v) for(int i = 0; i < sz(v); ++i)
using namespace std;
@mhmoodlan
mhmoodlan / A. Shaass and Oskols.cpp
Created October 6, 2017 06:35
#ElementaryMath #Implementation #Codeforces #Solved
//http://codeforces.com/contest/294/problem/A
#include <bits/stdc++.h>
#define ll long long
#define sz(v) ((int) ((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define lp(i, n) for(int i = 0; i < (int)(n); ++i)
#define rep(i, v) for(int i = 0; i < sz(v); ++i)
using namespace std;
@mhmoodlan
mhmoodlan / A. Die Roll.cpp
Created October 6, 2017 06:19
#ElementaryMath #Probability #Codeforces #Solved #Easy
//http://codeforces.com/contest/9/problem/A
#include <bits/stdc++.h>
#define ll long long
#define sz(v) ((int) ((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define lp(i, n) for(int i = 0; i < (int)(n); ++i)
#define rep(i, v) for(int i = 0; i < sz(v); ++i)
using namespace std;
@mhmoodlan
mhmoodlan / 10003 - Cutting Sticks.cpp
Created October 5, 2017 08:20
#DP #NestedRanges #UVa #Solved
//https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=944
#include <bits/stdc++.h>
#define ll long long
#define sz(v) ((int) ((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define lp(i, n) for(int i = 0; i < (int)(n); ++i)
#define rep(i, v) for(int i = 0; i < sz(v); ++i)
using namespace std;
@mhmoodlan
mhmoodlan / 180 - Eeny Meeny-NOT-AC.cpp
Created September 28, 2017 08:44
#DP #JousephProblem #Adhoc #UVa #NotSolved
//https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=116
#include <bits/stdc++.h>
#define ll long long
#define sz(v) ((int) ((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define lp(i, n) for(int i = 0; i < (int)(n); ++i)
#define rep(i, v) for(int i = 0; i < sz(v); ++i)
using namespace std;