写在前面实现思路测试用例input:output:ac代码学习代码
原创
2022-08-23 15:47:21
18阅读
Game of ConnectionsTime Limit: 2000/1000 MS (Java/Oth
转载
2012-08-30 20:23:00
72阅读
2评论
题目题意:给定图的边信息,问待查询顶点集是否是图的顶点覆盖集,顶点覆盖集:图中所有的边至少一个顶点在顶点集中。tip:将待查顶点集所有连边全部去掉,在判断是否还有边即可#include<iostream>#include<algorithce std;vector<int&g...
原创
2023-06-27 10:23:11
92阅读
1 class Solution:
2 def isArmstrong(self, N: int) -> bool:
3 ns = str(N)
4 lens = len(ns)
5 sums = 0
6 for n in ns:
7 cur = int(n)
8 su
转载
2019-07-27 23:32:00
75阅读
A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with
转载
2020-04-20 00:03:00
151阅读
2评论
题目:给你一棵树。找到最小的顶点集合,使得全部的边至少有一个顶点在这个集合中。分析:树形dp,图论,最小顶点覆盖。 方案1:树形dp。分别记录每一个节点取和不取的最优解f(k。0)与f(k,1); 每一个节点的状态取决于子树,子树的根都不选,则他必选;否则取最小; ...
转载
2016-01-02 14:29:00
43阅读
Game of Connections HDU - 1134
This is a small but ancient game. You are supposed to write down the numbers 1, 2, 3, ... , 2n - 1, 2n consecutively in clockwise order on the ground to
原创
2023-06-09 14:08:17
52阅读
1134Vertex Cover(25分)Avertex coverof a graph is a set of vertices such that each edge of the graph is incident to at letex sets, you ...
原创
2023-03-02 05:46:25
94阅读
题目大意:给你N个数,要求你选出数字连续的子集,使得子集内的数字和能被k整出解题思路:设dp[i]为余数为i的前缀和出现了几次,如果两次前缀和的余数相等了,表示中间所加的数刚好是k的倍数了,这就可以抽离出来了,将其分成段,再取#include <cstdio>#include <cstring>typedef long long LL;const int N = 100010;LL dp[N]
原创
2023-04-07 11:01:30
51阅读
题目描述也许你早就知道阶乘的含义,N阶乘是由1到N相乘而产生,如:12!= 1 \times 2 \times 3 \times 4 \times 5 \times 6 \times 7 \times 8 \times 9 \times 10 \times 11 \times 12 = 479,001,60012!=1×2×3×4×5×6×7×8×9×10×11×12=479,001,60...
原创
2021-07-12 10:31:30
38阅读
判断点覆盖,用前向星直接切。 idx存储边的下标,idx^1为反向边,注意边数组开两倍,因为存的双边。 const int N=1e4+10; int h[N],e[N<<1],ne[N<<1],idx; bool vis[N<<1]; int n,m,q; void add(int a,int b
转载
2021-03-03 17:16:00
124阅读
A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with
转载
2018-03-14 19:45:00
68阅读
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1134题意 给出一个n 然后有2n个点 给两个点连一条边,最后连N条边,要求所有的边不能够交叉 问最多有几分连边的方式思路我们可以发现 一个点 可以和它相隔偶数个点 的...
转载
2018-04-25 22:32:00
85阅读
题目描述也许你早就知道阶乘的含义,N阶乘是由1到N相乘而产生,如:12!= 1 \times 2 \times 3 \times 4 \times 5 \times 6 \times 7 \times 8 \times 9 \times 10 \times 11 \t...
原创
2021-09-02 11:03:46
76阅读
PAT 1134 C++版【updating…】1.题意输入:给出一个无向图的边节点信息;给出数组待查询顶点的集合让你判断图中的任一条边的顶点是否都在这个顶点的集合中?如果都在则称为vertex cover,否则不是。2.分析暴力求解直接根据输入新建一个结构体数组,其中保留的是每条边left,right左右两个节点,以及一个访问标志位。在输入节点集合之后,使用双重循环遍历一遍,表示边...
原创
2021-07-08 11:38:30
79阅读
1134 Vertex Cover (25 point(s))A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with
原创
2022-09-15 11:01:55
48阅读
Given an integer n, return true if and only if it is an Armstrong number. The k-digit number n is an Armstrong number if and only if the kth power of ...
转载
2021-07-03 00:04:00
100阅读
2评论
PAT 1134 C++版【updating…】1.题意输入:给出一个无向图的边节点信息;给出数组待查询顶点的集合让你判断图中的任一条边的顶点是否都在这个顶点的集合中?如果都在则称为vertex cover,否则不是。2.分析暴力求解直接根据输入新建一个结构体数组,其中保留的是每条边left,right左右两个节点,以及一个访问标志位。在输入节点集合之后,使用双重循环遍历一遍,表示边...
原创
2022-01-26 10:09:20
78阅读
题目传送门一、BFS方法#include <bits/stdc++.h>using namespace std;const int N = 4e5 + 10;const int mod = 100003;int h[N], ne[N], e[N], idx;void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a]
原创
2022-03-29 15:18:02
153阅读
时间限制: 1000 ms ...
转载
2019-04-29 09:11:00
225阅读
2评论