poj 2240 Bellman-Flod 求环】的更多相关文章

Arbitrage 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/I Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose…
Arbitrage Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys 0.5 British pound, 1 British pound buys 10.0 Frenc…
Time Limit: 1000MS Memory Limit: 65536K Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys 0.5 Brit…
http://poj.org/problem?id=2240 深刻体现了自己代码能力有问题外加改模板能力有问题.外加Debug有问题.以后做到: 1.算法原理能够轻易弄出来. 2.代码模板自己收集各种使用方法,以及已经的做过的改变的方法: 3.没有完整清晰的思路不写程序: 4.在Debug时没有基本绝对的把握,不点击"编译+执行",不乱试 回到这道题: 我主要是想把Bellman-Ford的模板改为链式前向星的,然后就各种悲剧调试...... 学到三点:1.比例的初始化,求最大,源1.…
POJ 2240 Arbitrage / ZOJ 1092 Arbitrage / HDU 1217 Arbitrage / SPOJ Arbitrage(图论,环) Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For exa…
POJ 1860 Currency Exchange / ZOJ 1544 Currency Exchange (最短路径相关,spfa求环) Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations onl…
/* poj 1474 Video Surveillance - 求多边形有没有核 */ #include <stdio.h> #include<math.h> const double eps=1e-8; const int N=103; struct point { double x,y; }dian[N]; inline bool mo_ee(double x,double y) { double ret=x-y; if(ret<0) ret=-ret; if(ret&…
题目传送门 /* 最短路:Floyd模板题 只要把+改为*就ok了,热闹后判断d[i][i]是否大于1 文件输入的ONLINE_JUDGE少写了个_,WA了N遍:) */ #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <string> #include <map> #include <cmath>…
题目链接: 题目 E. New Reform time limit per test 1 second memory limit per test 256 megabytes inputstandard input outputstandard output 问题描述 Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities…
链接:poj 2240 题意:首先给出N中货币,然后给出了这N种货币之间的兑换的兑换率. 如 USDollar 0.5 BritishPound 表示 :1 USDollar兑换成0.5 BritishPound. 问在这N种货币中是否存在货币经过若干次兑换后,兑换成原来的货币能够使货币量添加. 思路:本题事实上是Floyd的变形.将变换率作为构成图的路径的权值.只是构成的图是一个有向图. 最后将松弛操作变换为:if(dis[i][j]<dis[i][k]*dis[k][j]). #includ…
Arbitrage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 21300   Accepted: 9079 Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currenc…
/* poj 1279 Art Gallery - 求多边形核的面积 */ #include<stdio.h> #include<math.h> #include <algorithm> using namespace std; const double eps=1e-8; struct point { double x,y; }dian[20000+10]; point jiao[203]; struct line { point s,e; double angle;…
题目描述 有n个同学(编号为1到n)正在玩一个信息传递的游戏.在游戏里每人都有一个固定的信息传递对象,其中,编号为i的同学的信息传递对象是编号为Ti同学. 游戏开始时,每人都只知道自己的生日.之后每一轮中,所有人会同时将自己当前所知的生日信息告诉各自的信息传递对象(注意:可能有人可以从若干人那里获取信息,但是每人只会把信息告诉一个人,即自己的信息传递对象).当有人从别人口中得知自己的生日时,游戏结束.请问该游戏一共可以进行几轮? 输入输出格式 输入格式: 输入共2行. 第1行包含1个正整数n表示…
POJ 3080 Blue Jeans (求最长公共字符串) Description The Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousands of contributors to map how the Earth was populated. As an IB…
Arbitrage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions:27167   Accepted: 11440 Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currenc…
#include<stdio.h> #include<string.h> #include<queue>//只需判断是否有正环路径就可以了 using namespace std; #define N  200 struct node { double r,c; }map[N][N]; double maxvalue[N],h; int n,cou[N]; int  bellmanford(int start) {   queue<int>q;   int…
http://poj.org/problem?id=2240 题意:货币兑换,判断最否是否能获利. 思路:又是货币兑换题,Belloman-ford和floyd算法都可以的. #include<iostream> #include<algorithm> #include<string> #include<cstring> #include<map> using namespace std; + ; int n, m; string s1,s2;…
d[i]代表从起点出发可以获得最多的钱数,松弛是d[v]=r*d[u],求最长路,看有没有正环 然后这题输入有毒,千万别用cin 因为是大输入,组数比较多,然后找字符串用strcmp就好,千万不要用map 这题刚开始我T了(用的map),还以为组数很多卡spfa呢,然后我上网看了看都是floyd的,然后我用floyd写了一发,891ms过了 然后我感觉spfa的复杂度也不是很大,就是看有没有正环,所以我觉得可能是map+cin的锅,然后改了一发,用的spfa,47ms过 真是,算了,实质是本蒟蒻…
题目链接:http://poj.org/problem?id=2240. Floyd算法修改一下,我要最大路径(通过转汇率变到最大)改成max. #include <iostream> #include <string.h> #include <stdio.h> #include <algorithm> using namespace std; ][]; int n; int main() { ; while(scanf("%d",&am…
和POJ1860差不多,就是用bellmanford判读是否存在正环,注意的是同种货币之间也可以交换,就是说:A货币换A货币汇率是2的情况也是存在的. #include<stdio.h> #include<string.h> #include<cstring> #include<string> #include<math.h> #include<queue> #include<algorithm> #include<…
题意: 给了n种硬币的名称,给了m种硬币间的转换关系. 从任意兑换地点开始兑换,看是否能够通过兑换的方式增加金钱. 思路: 用SPFA不断对各个点进行松弛操作,寻找正权值的环.如果找到则输出Yes. 这题测试的时候竟然发现dis数组写成int型... #include<stdio.h> #include<map> #include<string.h> #include<string> #include<iostream> #include<…
你们见过这么诡异的FLOYD吗? 先上题. [Description] 货币的汇率存在差异.比如,如果1美元购买0.5英镑,1英镑买10法郎.而1法国法郎买0.21美元.然后,通过转换货币,一个聪明的交易者能够从1美元买0.5 * 10 * 0.21 = 1.05美元,获利5%. 你的任务是写一个程序,以一个货币汇率列表的作为输入,然后确定能不能获利. [Intput] 输入包括多组測试数据,每组数据第一行一个数n(1<=n<=30),表示有n中货币,接下来n行.每行一种货币名称,名称内不会出…
题目:http://poj.org/problem?id=2240 题意:给定n个货币名称,给m个货币之间的汇率,求会不会增加 和1860差不多,求有没有正环 刚开始没对,不知道为什么用 double往结构体里传值的时候 会去掉小数点后的 数 #include <iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<stack> #include<qu…
http://poj.org/problem?id=2240 题意:有些人会利用货币的不用汇率来进行套现,比如1美元换0.5英镑,而1英镑又可以换10法郎,而1法郎又可以换0.21的美元,那么经过货币的汇率转换后,它就可以获得1.05倍原来的美元. 现在给你N中货币,m种货币的汇率,求是否可以获利. 思路:首先这个是给你一些货币,那么我们可以把货币和数字建立一个映射.然后再用他给的汇率以及数字建立一个邻接矩阵.用一次floyd后对对角线的数字进行判断,如果大于1,那么说明可以获利,不然就不能获利…
题目链接:http://poj.org/problem?id=3621 思路:之前做过最小比率生成树,也是属于0/1整数划分问题,这次碰到这道最优比率环,很是熟悉,可惜精度没控制好,要不就是wa,要不就是tle,郁闷啊!实在是懒得码字,直接copy吧: 题目的意思是:求一个环的{点权和}除以{边权和},使得那个环在所有环中{点权和}除以{边权和}最大.令在一个环里,点权为v[i],对应的边权为e[i], 即要求:∑(i=1,n)v[i]/∑(i=1,n)e[i]最大的环(n为环的点数), 设题目…
链接: http://poj.org/problem?id=2240 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22010#problem/F Arbitrage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13067   Accepted: 5493 Description Arbitrage is the use of discrepancies i…
题目链接:http://poj.org/problem?id=2240 题目就是要通过还钱涨自己的本钱最后还能换回到自己原来的钱种. 就是判一下有没有负环那么就直接用bellman_ford来判断有没有负环 #include <iostream> #include <cstring> #include <string> using namespace std; int n , m , s , a , b , counts; double rx , ry , cx , c…
 POJ 3259 Wormholes Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu   Description While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way…
Time Limit: 1000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u   Java class name: Main [Submit] [Status] [Discuss] Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency in…
1506 传话  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 白银 Silver 题解       题目描述 Description 一个朋友网络,如果a认识b,那么如果a第一次收到某个消息,那么会把这个消息传给b,以及所有a认识的人. 如果a认识b,b不一定认识a. 所有人从1到n编号,给出所有“认识”关系,问如果i发布一条新消息,那么会不会经过若干次传话后,这个消息传回给了i,1<=i<=n. 输入描述 Input Description 第一行是n和m,表示人数…