时间限制:0.25s 空间限制:4M 题意: 有n(n<=16000)个小镇,每两个小镇有且仅有一条路径相连.每个小镇有一个收益x(-1000<=x<=1000). 现在要求,选择一些小镇,满足下面两点要求: 1.选择的小镇都能互相到达,并且路径上的小镇也被选择了. 2.选择的小镇的收益和最大. 输入 一个整数n,接下来n个整数,代表这n个小镇的收益. 接下来n-1行,每行两个整数代表这两个小镇有道路直接相连. 输出 一个整数,代表最大的收益 Sample Input 5 -1 1 3…
143. Long Live the Queen time limit per test: 0.25 sec. memory limit per test: 4096 KB The Queen of Byteland is very loved by her people. In order to show her their love, the Bytelanders have decided to conquer a new country which will be named accor…
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traffic Lights 最短路 104 Little Shop of Flowers 动态规划 105 Div 3 找规律 106 The Equation 扩展欧几里德 107 987654321 Problem 找规律 108 Self-numbers II 枚举+筛法递推 109 Magic of Dav…
本解题报告 乱抄,乱写,随性随心,不喜多喷! SGU 142: 思路:一个string的字串不会超过2^20个,我们枚举出来就好了. 我出错点:数组RE #include<stdio.h> #include<math.h> #include<algorithm> #include<string.h> #include<string> #include<iostream> #include<set> #include<…
SGU 109 题意:一个n*n的矩形,起点在1,1然后每次给你一个操作,走ki步,然后你可以删除任意一个点这次步走不到的,删了就不能再走了,然后问构造这种操作,使得最后删除n*n-1个点 剩下一个点,这个人最终的目的就在那,还要求每次走的步数要递增,n<=ki<300 收获:奇妙的构造,每次走奇数点,就会走到和自己奇偶不一样的点,(1,1)为偶点,(2,3)为奇点,然后第一次先删除n步走不到的点,那么接下来的点到起点的距离就是0-n,那么我们就可以 删n次,然后每一次删距离为n-i的点,最终…
SGU 解题报告(持续更新中...Ctrl+A可看题目类型): SGU101.Domino(多米诺骨牌)------------★★★type:图 SGU102.Coprimes(互质的数) SGU103.TrafficLights(交通灯)---------★★type:图 SGU104.LittleShopofFlowers(小花店)---★type:DP SGU105.Div3(整除3) SGU106.TheEquation(方程)-------------★type:数论 SGU107.…
水概率....SGU里难得的水题.... 495. Kids and Prizes Time limit per test: 0.5 second(s)Memory limit: 262144 kilobytes input: standardoutput: standard ICPC (International Cardboard Producing Company) is in the business of producing cardboard boxes. Recently the…
Long Live the Queen Time Limit:250MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u Description The Queen of Byteland is very loved by her people. In order to show her their love, the Bytelanders have decided to conquer a new country which…
sgu 101 - Domino Time Limit:250MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u Description Dominoes – game played with small, rectangular blocks of wood or other material, each identified by a number of dots, or pips, on its face. The bl…
http://acm.sgu.ru/problem.php?contest=0&problem=495 题意:N个箱子M个人,初始N个箱子都有一个礼物,M个人依次等概率取一个箱子,如果有礼物则拿出礼物放回盒子,如果没有礼物则不操作.问M个人拿出礼物个数的期望.(N,M<=100000) #include <cstdio> using namespace std; double mpow(double a, int n) { double r=1; while(n) { if(n&…