Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \documentclass[a4paper]{article}
- \usepackage[utf8]{inputenc}
- \usepackage{url}
- \usepackage{minted}
- \usepackage{graphicx}
- \title{UAP Training}
- \author{Rafid Bin Mostofa}
- \date{July 13, 2019}
- \begin{document}
- \maketitle
- \hline
- \tableofcontents
- \pagebreak
- \section{Chinese Remainder Theorem}
- This is a good source: \url{https://cp-algorithms.com/algebra/chinese-remainder-theorem.html} \\
- \subsection{Problems}
- \begin{itemize}
- \item \url{http://www.lightoj.com/volume_showproblem.php?problem=1319} [\ref{code:monkey}]
- \item RUET 2019 A
- \end{itemize}
- \section{Flow}
- \subsection{Maximum Flow}
- \begin{figure}[h]
- \centering
- \includegraphics{maxflow}
- \label{fig:my_label}
- \end{figure}
- \begin{itemize}
- \item \url{https://www.topcoder.com/community/competitive-programming/tutorials/maximum-flow-section-1/}
- \item \url{https://www.topcoder.com/community/competitive-programming/tutorials/maximum-flow-section-2/}
- \end{itemize}
- Problems: \url{http://www.lightoj.com/volume_problemcategory.php?user_id=29559&category=Max%20Flow/Min%20Cut}
- \subsection{Min Cost Max Flow}
- Source: \url{https://cp-algorithms.com/graph/min_cost_flow.html} \\ \\
- Problems: \url{http://www.lightoj.com/volume_problemcategory.php?user_id=29559&category=Min%20Cost%20Max%20Flow} \\
- Another Problem: \url{https://toph.co/p/alice-loves-to-play-game}
- \subsection{Bipartite Matching}
- \begin{itemize}
- \item Hopcroft Karp
- \item Kuhn
- \item Hungarian (Weighted)
- \end{itemize}
- \pagebreak
- \section{APPENDIX}
- \subsection{LightOJ 1319 - Monkey Tradition}
- \label{code:monkey}
- \begin{minted}{cpp}
- #include <bits/stdc++.h>
- using namespace std;
- typedef pair<long long, long long> pll;
- #define ff first
- #define ss second
- pll extendedEuclid(int a, int b) { // returns x, y | ax + by = gcd(a,b)
- if(b == 0) return pll(1, 0);
- else {
- pll d = extendedEuclid(b, a % b);
- return pll(d.ss, d.ff - d.ss * (a / b));
- }
- }
- long long modInv(int a, long long p) {
- pll ret = extendedEuclid(a, p);
- return ((ret.ff % p) + p) % p;
- }
- unsigned long long crt(vector<int> &rem, vector<int> &mod) {
- assert(rem.size() == mod.size());
- unsigned long long ret = 0;
- int n = rem.size();
- unsigned long long MOD = 1;
- for(int i=0; i<n; ++i) MOD *= mod[i];
- // you shouldn't run a n^2 loop inside crt
- // this case was exceptional and
- // the programmer was too lazy to optimize
- for(int i=0; i<n; ++i) {
- long long cur = rem[i];
- for(int j=0; j<n; ++j) {
- if(i == j) continue;
- cur = (cur * mod[j]);
- cur = (cur * modInv(mod[j], mod[i]));
- cur %= MOD;
- }
- ret = (ret + cur) % MOD;
- }
- return ret;
- }
- int main() {
- int t, tc=0;
- scanf("%d", &t);
- while(t--) {
- int n;
- scanf("%d", &n);
- vector<int> rem(n), mod(n);
- for(int i=0; i<n; ++i) cin >> mod[i] >> rem[i];
- unsigned long long res = crt(rem, mod);
- printf("Case %d: %llu\n", ++tc, res);
- }
- return 0;
- }
- \end{minted}
- \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement