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…
这一场两个和大数有关的题目,都用到了米勒拉宾算法,有点东西,备忘一下. 题目传送门 F. Divisions 传送门 这个题是求一个数的所有因子个数,但是数据比较大,1e18,所以是大数的题目,正常的求因数的或者求质因数的都过不了,因为这一场的K是米勒拉宾判大素数,先过的K题,所以这个题直接头铁用Miller_Rabin+Pollard_rho这两个东西+因子个数求解公式写过去了. 这两个算法的具体原理不清楚.从别人那里知道了一点. Miller_Rabin算法的作用是判断一个数是否是个素数,算…
K. Upside down primes 传送门 这个题就是把大数按字符串输进去,判断一下是不是素数,然后反转180度,先判断反转之后的东西是不是一个数,如果是的话,再把这个数判一下是不是素数,如果都满足条件就yes. 直接调用两次米勒拉宾判大素数就可以了. 代码: //K-米勒拉宾判大素数 #include<iostream> #include<algorithm> #include<cstring> #include<iomanip> #include…
先写这几道题,比赛的时候有事就只签了个到. 题目传送门 E. Excellent Engineers 传送门 这个题的意思就是如果一个人的r1,r2,r3中的某一个比已存在的人中的小,就把这个人添加到名单中. 因为是3个变量,所以按其中一个变量进行sort排序,然后,剩下的两个变量,一个当位置pos,一个当值val,通过线段树的单点更新和区间最值操作,就可以把名单确定. 代码: //E-线段树 #include<iostream> #include<cstdio> #include…
I. Interesting Integers 传送门 应该是叫思维题吧,反正敲一下脑壳才知道自己哪里写错了.要敢于暴力. 这个题的题意就是给你一个数,让你逆推出递推的最开始的两个数(假设一开始的两个数为x和y),而且要求x<=y. 通过找规律可以发现,这个题就是求解a*x+b*y=k这个方程的x和y的值,并且要x和y为最小满足条件的解.可以找规律出一个公式fi[i]*x+(fi[i-1]+fi[i])*y=n.因为不知道n具体是在第几步推出来的,所以for循环跑一遍预处理出来的斐波那契数列(存…
G. Growling Gears 传送门 此题为签到题,直接中学的数学知识点,一元二次方程的顶点公式(-b/2*a,(4*a*c-b*b)/4*a):直接就可以得到结果. 代码: #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #include<queue> #include<map> #inc…
include <iostream> #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <utility> #include <vector> #include <map> #include <queue> #include <stack> #include <c…
开始水一波博客 题目链接: A. Choosing Ice Cream 传送门 题意就是n个冰淇淋,骰子有k个面,问你是否能在公平的概率下转几次骰子能确定买哪个冰淇淋. 举个例子,假设我只有一个冰淇淋,我不用转骰子直接就会买这个,所以转骰子的次数是0,如果我有4个冰淇淋,2个骰子面,我可以先把冰淇淋abcd分成两部分,ab一组,cd一组,这是等概率的,我先转一次骰子确定是选ab组还是cd组,然后再转一次就可以确定买哪个了.如果我有6个冰淇淋,12个面,我可以每一种冰淇淋贴2个面,转一次就可以确定…
F. Runway Planning 传送门 题意简直就是有毒,中间bb一堆都是没用的,主要的意思就是度数大于180度的就先减去180度,然后除以10,四舍五入的值就是答案.如果最后结果是0就输出18就可以,其他没了,看懂题意就是水题. 代码: #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<…
B. Failing Components 传送门 题意就是单向图,从起点开始找最短路,然后统计一下个数就可以.方向是从b到a,权值为s. 直接最短路跑迪杰斯特拉,一开始用数组版的没过,换了一个队列版的过了. 代码: #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #include<queue> #inclu…
// 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<…
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>…
$$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: (寒假开黑gym)2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017) author: "luowentaoaa" catalog: true tags: mathjax: true - codeforces 传送门 付队! 许老师! B.Buildings (polya定理) 题意 B:给你m面墙,每面墙是n*n的格子,你有c种颜色,问你有多少种涂色方案.用po…
layout: post title: 2018 German Collegiate Programming Contest (GCPC 18) author: "luowentaoaa" catalog: true tags: mathjax: true - codeforces 传送门 付队博客 C.Coolest Ski Route (记忆化搜索) 题意 给出一个有向图,求出一个权值最长的链, 题解 暴力dfs会超时,所以直接储存每个起点能走到的最远距离 #include<…
$$2017-2018\ ACM-ICPC\ German\ Collegiate\ Programming\ Contest (GCPC 2017)$$ \(A.Drawing\ Borders\) \(B.Buildings\) Polya定理搞一搞 //#pragma GCC optimize("O3") //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<bits/std…
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…
John loves winter. Every skiing season he goes heli-skiing with his friends. To do so, they rent a helicopter that flies them directly to any mountain in the Alps. From there they follow the picturesque slopes through the untouched snow. Of course th…
Battle Royale games are the current trend in video games and Gamers Concealed Punching Circles (GCPC) is the most popular game of them all. The game takes place in an area that, for the sake of simplicity, can be thought of as a two-dimensional plane…
Ada, Bertrand and Charles often argue over which TV shows to watch, and to avoid some of their fights they have finally decided to buy a video tape recorder. This fabulous, new device can record kk different TV shows simultaneously, and whenever a sh…
Method ringing is used to ring bells in churches, particularly in England. Suppose there are 6 bells that have 6 different pitches. We assign the number 1 to the bell highest in pitch, 2 to the second highest, and so on. When the 6 bells are rung in…
In an unprecedented turn of events, goblins recently launched an invasion against the Nedewsian city of Mlohkcots. Goblins—small, green critters—love nothing more than to introduce additional entropy into the calm and ordered lives of ordinary people…
You're investigating what happened when one of your computer systems recently broke down. So far you've concluded that the system was overloaded; it looks like it couldn't handle the hailstorm of incoming requests. Since the incident, you have had am…
一个离散化的简单题: 我用的是STL来做的离散化: 好久没写离散化了,纪念一下! 代码: #include<cstdio> #include<cstring> #include<vector> #include<algorithm> #define maxn 5005 using namespace std; vector<int>ve; ]={,,,,, ,,,,,,}; struct node { int st,end; }no[maxn];…
A Drawing Borders 很多构造方法,下图可能是最简单的了 代码: #include<bits/stdc++.h> using namespace std; ; struct Point{ int x,y; }; Point a[maxn]; ; Point b[maxn]; ; vector<pair<double,double> > va; vector<pair<double,double> > vb; void checka(…
B .Battle Royale 题意:给你两个点A,B,以及一个圆S,保证两个点在圆外,且其连线与圆相交,求两点间最短距离. 思路:显然是要分别与圆相切,然后在圆弧想走,直到相交. 那么ans=与圆相交的直线距离+圆弧上的距离: 前者不难求. 后者的话有些抽象,因为不知道怎么取固定角度,但是如果想到atan2了就不难了,因为atan2求出的角度是固定了标准的,注意对用两个atan2求出来的角度求其夹角时,注意不要错过2pi:同时取min(angle,2*pi-angle).  还不懂的,看代码…
    Booking Pierre is in great trouble today! He is responsible for managing the bookings for the ACM (Acco- modation with Moderate Costs) hotel and has just realized that the booking software has a severe   bug. It has created overlapping and wrong…
A. Drawing Borders Unsolved. B. Buildings Unsolved. C. Joyride Upsolved. 题意: 在游乐园中,有n个游玩设施,有些设施之间有道路,给出每个设施需要花费的时间和价格,以及经过每条道路的时间,求从设施1出发恰好回到设施1恰好花费时间x的最小花费. 思路: $dist[i][j] 表示 第i个时刻 到第j个点的最小花费  从<t[1], 1> -> <x, 1>$ 跑最短路即可 #include <bit…
数值计算: 这种积分的计算方法很好,学习一下! 代码: #include <iostream> #include <cmath> using namespace std; ; double func(double a, double b, double x) { double r = a * exp(- x*x) + b * sqrt(x); return r*r; } double integrate(double a, double b, double h) { unsigne…