打赏

相关文章

POJ 2545 解题报告

这道题和之前的2247&#xff0c; 1338是一样的。唯一注意的地方是数据范围更大&#xff0c;不能用int了&#xff0c;用unsigned long long即可。 thestoryofsnow2545Accepted160K0MSC879B /* ID: thestor1 LANG: C TASK: poj2545 */ #include <iostream> #include &…

hdu2545树上战争

树上战争 Time Limit : 10000/4000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 4 Accepted Submission(s) : 4 Problem Description 给一棵树&#xff0c;如果树上的某个节点被某个人占据&#xff0c;则它的所有儿子都被占据&#xf…

ZOJ-2545

也比较简单&#xff0c;转化为对数计算就行了 #include<stdio.h> #include<math.h>int main() {int i, a[23], n 1;double sum 0, log2 log(2);for (i 2; i < 22; i){int max 1 << i;while (sum / log2 < max)sum log(n);a[i] n - 2;}while (sc…

2545 ACM 博客 比较树的路径长短

题目&#xff1a;http://acm.hdu.edu.cn/showproblem.php?pid2545 题意&#xff1a;比较树的路径长短 思路&#xff1a;利用数组存入父节点的值&#xff0c; 例如&#xff1a; 5 2 1 2 1 3 3 4 3 5 4 2 查找 4 进行了 3 4和1 3 两步&#xff0c;如何判断到达了根节点…

POJ 2545

还是一样的题&#xff0c;&#xff0c;&#xff0c;不解释。不过数据真的太弱了&#xff0c;竟然可以0ms过&#xff0c;&#xff0c;&#xff0c;&#xff0c;看来今天真的很水。。。。。。题目&#xff1a; Hamming Problem Time Limit: 1000MS Memory Limit: 65536KTotal Sub…

hdu-2545

并查集的扩展应用&#xff0c;求节点到根的距离 //求节点到根的距离 //r[i]存储节点 i 到根的距离#include <stdio.h> #include <iostream> #include <string.h> #include <algorithm> #include <stdlib.h>using namespace std;int p[100010]; i…

hdu2545

/* 分析&#xff1a; 简单并查集。 在网吧夜市刷题&#xff0c;桑不起呀&#xff0c;囧囧囧~~~ 2012-11-19 */ #include"stdio.h" #include"string.h" #define N 100011 int n,m; int pre[N]; int dis[N]; void build() {int i;for(i1;i<n;i) {pre[i]i;…

手机版浏览

扫一扫体验

微信公众账号

微信扫一扫加关注

返回
顶部