// Change of Scenery 1 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> #include <utility> #include <queue> using namespace std; typedef long long ll; typedef pair<…
K. Upside down primes 传送门 这个题就是把大数按字符串输进去,判断一下是不是素数,然后反转180度,先判断反转之后的东西是不是一个数,如果是的话,再把这个数判一下是不是素数,如果都满足条件就yes. 直接调用两次米勒拉宾判大素数就可以了. 代码: //K-米勒拉宾判大素数 #include<iostream> #include<algorithm> #include<cstring> #include<iomanip> #include…
这一场两个和大数有关的题目,都用到了米勒拉宾算法,有点东西,备忘一下. 题目传送门 F. Divisions 传送门 这个题是求一个数的所有因子个数,但是数据比较大,1e18,所以是大数的题目,正常的求因数的或者求质因数的都过不了,因为这一场的K是米勒拉宾判大素数,先过的K题,所以这个题直接头铁用Miller_Rabin+Pollard_rho这两个东西+因子个数求解公式写过去了. 这两个算法的具体原理不清楚.从别人那里知道了一点. Miller_Rabin算法的作用是判断一个数是否是个素数,算…
E.Extreme Sort 传送门 代码: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; ; int a[maxn]; int main(){ int n; scanf("%d",&n); ;i<n;i++) scanf("%d…
Divisions David is a young boy and he loves numbers. Recently he learned how to divide two numbers.David divides the whole day. He is happy if the result of the division is an integer, but he is not very amused if this is not the case. After quite a…
// Legacy Code #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <utility> #include <vector> #include <map> #include <queue> #include <stack>…
A:Adjoin the Networks One day your boss explains to you that he has a bunch of computer networks that are currently unreachable from each other, and he asks you, the cable expert's assistant, to adjoin the networks to each other using new cables. Exi…
$$2015\ German\ Collegiate\ Programming\ Contest\ (GCPC 15) + POI 10-T3$$ \(A.\ Journey\ to\ Greece\) 状压DP,TSP,先考虑找出这些关键点之间的最短路,然后就是旅行商问题,其中可以用一次\(taxi\),考虑\(dp\)状态为\(f[i][msk][tag]\),表示当前所在位置为\(i\)点,已经经过的节点集合为\(msk\),是否用过\(taxi\)的情况下,所化的最小时间,最后再从走遍了…
layout: post title: 2018 German Collegiate Programming Contest (GCPC 18) author: "luowentaoaa" catalog: true tags: mathjax: true - codeforces 传送门 付队博客 C.Coolest Ski Route (记忆化搜索) 题意 给出一个有向图,求出一个权值最长的链, 题解 暴力dfs会超时,所以直接储存每个起点能走到的最远距离 #include<…
2018 German Collegiate Programming Contest (GCPC 18) Attack on Alpha-Zet 建树,求lca 代码: #include <algorithm> #include <iterator> #include <iostream> #include <cstring> #include <cstdlib> #include <iomanip> #include <bit…