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; | |
| long long gcd(long long a, long long b){ // Find the GCD of two numbers using euclidian algorithm | |
| if(b==0) return a; | |
| return gcd(b, a%b); | |
| } | |
| int main(){ | |
| long long T, N, x, g; |
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 <cstdio> | |
| using namespace std; | |
| bool dfa(){ // Check what a DFA (Deterministic Finite Automaton) is and how it works. | |
| int state = 0; // DFAs are a bit complex for beginners, because it's an abstract mathematical | |
| char a = getchar(); // concept. But on the other hand the logic used for this specific problem | |
| char b = getchar(); // is very basic. Hence just the basic idea of the DFA concept should suffice. | |
| if(a==b) state = 2; | |
| char ch; | |
| while((ch=getchar()) != '\n'){ |
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> | |
| #include <sstream> | |
| #include <string> | |
| #include <queue> | |
| #include <deque> | |
| #include <set> | |
| #include <list> | |
| #include <map> |
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> | |
| #include <sstream> | |
| #include <string> | |
| #include <queue> | |
| #include <deque> | |
| #include <set> | |
| #include <list> | |
| #include <map> |
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
| #!/usr/bin/env python | |
| ''' | |
| CSS Validator Automation Script | |
| ******************************* | |
| Validates all css files in a given directory and writes | |
| errors and warnings to log files in a separate directory. | |
| Ganesh Prasad Sahoo (c) 2015 |
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
| /* | |
| * This is the solution to problem 'Princess Farida' on SPOJ. Link : http://www.spoj.com/problems/FARIDA/ | |
| * | |
| * The problem can be solved using Dynamic Programming, the recurrence | |
| * relation for the DP is : | |
| * DP[i] = INPUT[i] + MAX( DP[i-2], DP[i-3] ) ... Think yourself 'why ?' | |
| * | |
| * Now, as we see that the DP requires only upto 3rd previous term, we can | |
| * minimize the storage required to 4 values only and use a cyclic array | |
| * for the DP. Carefully study the solution to see how. |
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
| /* | |
| * *WARNING* | |
| * If you are not familiar with bit manipulations and bitwise programming | |
| * go study them first. | |
| * | |
| ************************************************************************** | |
| * | |
| * This is the solution to the practice problem 'Breaking into Atoms' | |
| * on Codechef. Link to problem : http://www.codechef.com/problems/ATOMS | |
| * |
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
| #ifndef NETSEC_MODULAR_HPP_INCLUDED__ | |
| #define NETSEC_MODULAR_HPP_INCLUDED__ | |
| class modularInverseException: public std::exception{ | |
| virtual const char *what() const throw(){ | |
| return "Modular Inverse does not exist in this case."; | |
| } | |
| } modularInverseDoesNotExist; | |
| template<int Mod> |
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 "modular.hpp" | |
| using namespace std; | |
| int main(){ | |
| modular<7> a,b,c,d; | |
| a=3; | |
| b=8; | |
| c=-5; | |
| cout<<a()<<" "<<b()<<" "<<c()<<endl; // expected 3 1 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
| tree = [0 for x in range(1000)] | |
| def countNodes(root): | |
| pass | |
| def addChildren(children, parent): | |
| tree[parent<<1] = children[0] | |
| tree[parent<<1|1] = children[1] |