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
import qualified Data.Map as M | |
import Data.Map ((!)) | |
fib :: Integer -> Integer | |
fib n = fst $ fib_aux M.empty n | |
fib_aux mp 0 = (1,mp) | |
fib_aux mp 1 = (1,mp) | |
fib_aux mp n | M.member n mp = (mp!n,mp) | |
| otherwise = (next,nmp) |
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
// {{{ $VIMCODER$ <-------- | |
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}} | |
#include <algorithm> | |
#include <vector> | |
#include <iostream> | |
#include <sstream> | |
#include <cmath> | |
#include <queue> | |
#include <unordered_map> | |
#include <numeric> |
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
{-# LANGUAGE TemplateHaskell #-} | |
import Language.Haskell.TH | |
sequence [funD (mkName "main") | |
[clause [] (normalB (appE (varE 'putStrLn) (stringE "Hello, TH!"))) []] | |
] |
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 <string> | |
#include <cstring> | |
#include <algorithm> | |
using namespace std; | |
int main(){ | |
string s,t; | |
cin>>s>>t; | |
int n = s.length(),m = t.length(); | |
int dp[n][m]; |
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 <algorithm> | |
#include <vector> | |
using namespace std; | |
int main(){ | |
int n; | |
cin>>n; | |
vector<int> vec(n); | |
for (int& i : vec) cin>>i; | |
constexpr int INF = 1e8; |
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 <algorithm> | |
#include <sstream> | |
#include <cmath> | |
#include <unordered_map> | |
using namespace std; | |
class PalindromePermutations { | |
public: | |
double palindromeProbability(string word) { | |
int len = word.size(); | |
int odd = len%2; |
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 <algorithm> | |
#include <vector> | |
using namespace std; | |
class BuildingHeights { | |
public: | |
int minimum(vector <int> heights) { | |
const int N = heights.size(); | |
sort(heights.begin(),heights.end()); | |
vector<int> accum(N); | |
accum[0] = heights[0]; |
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 <string> | |
#include <boost/spirit/include/qi.hpp> | |
using namespace boost::spirit; | |
int main(){ | |
std::string input = "123, 456.789"; | |
int n1; | |
double n2; | |
auto first = input.begin(),last = input.end(); | |
bool success = qi::parse(first,last, |
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 <boost/spirit/include/qi.hpp> | |
#include <boost/spirit/include/phoenix.hpp> | |
using namespace boost::spirit; | |
using namespace boost; | |
template<class It> | |
struct bool_grammar : qi::grammar<It,bool(),ascii::space_type> { | |
qi::rule<It,bool(),ascii::space_type> constant,formula; | |
bool_grammar() : bool_grammar::base_type(formula) { | |
using qi::lit; |
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
// {{{ $VIMCODER$ <-------- | |
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}} | |
#include <algorithm> | |
#include <vector> | |
#include <iostream> | |
#include <sstream> | |
#include <cmath> | |
#include <queue> | |
#include <unordered_map> | |
#include <numeric> |
OlderNewer