摘要: problemsolutioncodes//并查集及补集//凡是与i+n节点在同一个集合里的,都是不能与i在同一个集合里的。#include#includeusing namespace std;struct Edge{ int u, v, w; }e[100010]... 阅读全文
posted @ 2018-05-24 21:42 gwj1139177410 阅读(100) 评论(0) 推荐(0) 编辑
摘要: problemsolutioncodes//1.计算几何求第四点坐标, 方法很多//2.虚点,到A城市的四个机场边权都为0//3.SPFA跑最短路#include#include#include#include#include#includeusing namespa... 阅读全文
posted @ 2018-05-24 21:40 gwj1139177410 阅读(145) 评论(0) 推荐(0) 编辑
摘要: problem给出两个数(x,y)。 求出满足以下2个条件的所有(p,q)的个数。 1、p,q是正整数 2、p,q以x为最大公约数,以y为最小公倍数。solution最大公约数和最小公倍数的乘积就是原两个数的积先把两数相乘,再遍历他的因子即可。codes#includ... 阅读全文
posted @ 2018-05-24 21:38 gwj1139177410 阅读(186) 评论(0) 推荐(0) 编辑
摘要: problem在N×N的棋盘里面放K个国王每个国王会攻击它周围的一圈共8个格子使他们互不攻击,共有多少种摆放方案N using namespace std;const int maxn = 512;typedef long long LL;int c1[maxn], ... 阅读全文
posted @ 2018-05-24 21:12 gwj1139177410 阅读(111) 评论(0) 推荐(0) 编辑
摘要: problem有n只怪打败第i只怪物,消耗d[i]点生命值,恢复a[i]点生命值。任何时候你的生命值都不能降到0(或0以下)请问是否存在一种打怪顺序,使得你可以打完这n只怪物而不死掉n #includeusing namespace std;const int max... 阅读全文
posted @ 2018-05-24 21:01 gwj1139177410 阅读(124) 评论(0) 推荐(0) 编辑
摘要: problem平面直角坐标系上有n个点。在x轴上找尽量少的点,并以这些点为圆心画一个半径为d的圆,使得给定的点都在画出来的圆里。求最少要画的点数,如果不能输出-1。solution一、不能的情况 当且仅当,x轴上所有点到该点的距离都超过了d(即最短距离情况下,他到x轴... 阅读全文
posted @ 2018-05-24 20:45 gwj1139177410 阅读(95) 评论(0) 推荐(0) 编辑
摘要: problemsolutioncodes//思路就是对于每个状态下的字符串,枚举可以替换的部分替换作为下一个新的状态。#include#include#include#includeusing namespace std;int n = 1, flag;string ... 阅读全文
posted @ 2018-05-24 13:33 gwj1139177410 阅读(126) 评论(0) 推荐(0) 编辑
摘要: problemsolutioncodes//mdzz计算机根本不可能会赢???#include#define maxn 510using namespace std;int a[maxn][maxn], ans;int main(){ int n; cin>>... 阅读全文
posted @ 2018-05-24 13:31 gwj1139177410 阅读(116) 评论(0) 推荐(0) 编辑
摘要: problemsolutioncodes#include#include#includeusing namespace std;const int maxn = 5050;struct node{ int id, score; }a[maxn];int cmp(nod... 阅读全文
posted @ 2018-05-24 13:29 gwj1139177410 阅读(99) 评论(0) 推荐(0) 编辑
摘要: problemsolutioncodes#includeusing namespace std;int n, k, a[30], ans;int is_prime(int n){ if(n == 1 || n == 0)return 0; if(n == ... 阅读全文
posted @ 2018-05-24 13:27 gwj1139177410 阅读(120) 评论(0) 推荐(0) 编辑
选择