题目链接:戳我 #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<cmath> #include<vector> using namespace std; #define MAXN 8010 #define mod 1000000007 #define ll long long int n,m,a[MAXN],flag[…
描述 无向连通图 G 有 n 个点,n-1 条边.点从 1 到 n 依次编号,编号为 i 的点的权值为 WiWi, 每条边的长度均为 1.图上两点(u, v)的距离定义为 u 点到 v 点的最短距离.对于图 G 上的点对(u, v),若它们的距离为 2,则它们之间会产生WuWu×WvWv的联合权值. 请问图 G 上所有可产生联合权值的有序点对中,联合权值最大的是多少?所有联合权值之和是多少? 格式 输入格式 第一行包含 1 个整数 n. 接下来 n-1 行,每行包含 2 个用空格隔开的正整数 u…
坦克大战 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on computer now. What we are discussing is a simple edition of this game. Given a map that…
还是先看题吧: 试题描述 无向连通图 G 有 n 个点,n-1 条边.点从 1 到 n 依次编号,编号为 i 的点的权值为 Wi ,每条边的长度均为 1.图上两点(u, v)的距离定义为 u 点到 v 点的最短距离.对于图 G 上的点对(u, v),若它们的距离为 2,则它们之间会产生Wu * Wv 的联合权值.请问图 G 上所有可产生联合权值的有序点对中,联合权值最大的是多少?所有联合权值之和是多少? 输入 第一行包含 1 个整数 n.接下来 n-1 行,每行包含 2 个用空格隔开的正整数 …
传送门 https://www.cnblogs.com/violet-acmer/p/9937201.html 题解: 相关变量解释: int n; int fa[maxn];//fa[i] : i的父亲节点 int w[maxn];//w[i] : i的权值 long long sum[maxn];//sum[i] : i节点的所有儿子节点的权值和 int maxSon1[maxn];//maxSon1[i] : i节点的所有儿子中权值最大值(如果有超过两个儿子) int maxSon2[ma…
Description During the trip, Yehan and Linlin pass a cave, and there is a board at the door, which says if you have enough ambition, you will get lots of money from me. At the beginning of the cave, you will get one dollar, and then, if you go from A…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6464 免费送气球 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 264 Accepted Submission(s): 53 Problem Description 又到了GDUT一年一度的程序设计竞赛校赛的时间啦.同学们只要参加校赛,…
传送门:http://poj.org/problem?id=3565 Ants Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 7650 Accepted: 2424 Special Judge Description Young naturalist Bill studies ants in school. His ants feed on plant-louses that live on apple tree…
传送门:http://poj.org/problem?id=2195 Going Home Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 26151 Accepted: 13117 Description On a grid map there are n little men and n houses. In each unit time, every little man can move one unit st…