标签:color not return def inpu red desc 矛盾 define
1 #include<iostream> 2 #include<map> 3 #include<vector> 4 #include<cstring> 5 #define a mapp[s1] 6 #define b mapp[s2] 7 using namespace std; 8 double z[10][10],kk[10]; 9 string s[10]; 10 map<string,int> mapp; 11 int cnt,ans,n; 12 double k[10]; 13 int flag[10][10]; 14 double minn(double aa,double bb) {if (aa>bb) return bb; else return aa;} 15 int main () 16 { 17 char c; 18 string s1,s2; 19 cin>>n; 20 double x,y; 21 for (int i=1;i<=n;i++) 22 { 23 cin>>x>>s1; if (!a) {a=++cnt; s[a]=s1;} 24 cin>>c; 25 cin>>y>>s2; if (!b) {b=++cnt; s[b]=s2;} 26 z[a][b]=y/x; 27 z[b][a]=x/y; 28 } 29 for (int k=1;k<=cnt;k++) 30 for (int i=1;i<=cnt;i++) 31 for (int j=1;j<=cnt;j++) 32 if (z[i][j]==0&&z[i][k]!=0&&z[k][j]!=0) 33 z[i][j]=z[i][k]*z[k][j]; 34 int m,l; 35 cin>>m>>s1; 36 l=a; 37 int t1,g1,wz; 38 double t2=1e9; 39 double g2; 40 for (int i=1;i<=cnt;i++) 41 { 42 if (i==l||!z[l][i]) continue; 43 g2=m*z[l][i]; 44 g1=(int)(g2); 45 if (g2-g1>1e-9) ++g1; 46 if (g1>1e5) continue; 47 g2=g1*z[i][l]-m; 48 if (g2<t2) 49 { 50 t1=g1; 51 t2=g2; 52 wz=i; 53 } 54 } 55 cout<<t1<<" "<<s[wz]; 56 }
标签:color not return def inpu red desc 矛盾 define
原文地址:https://www.cnblogs.com/zjzjzj/p/11116191.html