| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
代码In Reply To:有路过的请看下这组数据!! Posted by:201321131067 at 2015-10-21 15:18:06 我的代码如下:
//1860 Currency Exchange
#include<stdio.h>
#include<string.h>
#include<queue>
#define max 105
struct node{
int v,next;
double r,c;//汇率,手续费
};
struct poj{
int id;
double value;
};
double money[max];
int n,m,s,head[max],end=0;
node point[max*2];
void add(int u,int v,double r,double c){
point[end].v=v;
point[end].r=r;
point[end].c=c;
point[end].next=head[u];
head[u]=end++;
}
bool spaf(){
poj u,temp;
u.id=s;
u.value=money[s]=1.0;
std::queue<poj> q;
q.push(u);
while(!q.empty()){
u=q.front();q.pop();
for(int i=head[u.id];i!=-1;i=point[i].next){
temp.id=point[i].v;
temp.value=u.value*(100-point[i].c)*point[i].r/100;
if(money[temp.id]<temp.value){
money[temp.id]=temp.value;
q.push(temp);
if(temp.value>1.0&&temp.id==s) return true;
}
}
}
return false;
}
int main(){
memset(head,-1,sizeof(head));
memset(money,0,sizeof(money));
int u,v;
double rst,cst,rts,cts;
scanf("%d%d%d%lf",&n,&m,&s,&money[0]);
for(int i=0;i<m;i++){
scanf("%d%d%lf%lf%lf%lf",&v,&u,&rst,&cst,&rts,&cts);
add(u,v,rst,cst);
add(v,u,rts,cts);
}
if(spaf()) printf("YES\n");
else printf("NO\n");
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator