![](https://i-blog.csdnimg.cn/direct/fc821ffcc4bc4a3199e3e1bf63a983ff.png)
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<map>
using namespace std;
char opt;
string s,s1;
map<string,string> ds;
string find(string x){
if(x==ds[x]) return x;
return ds[x] = find(ds[x]);
}
int main(){
cin>>opt;
while(opt != '$'){
cin>>s;
if(opt == '#'){
s1=s;
if(ds[s]=="") ds[s]=s;
}else if(opt == '+'){
ds[s] = s1;
}else{
cout<<s<<" "<<find(s)<<endl;
}
cin>>opt;
}
return 0;
}
P1163 银行贷款
![](https://i-blog.csdnimg.cn/direct/88744aab379f4ad8a7abde3710feb945.png)
#include <iostream>
#include <algorithm>
#include<math.h>
#include <deque>
using namespace std;
int main(){
int loan,pay,month;
cin>>loan>>pay>>month;
double l=0,r=10;double mid,t;
while (l<r) {
mid=(l+r)/2;
t=loan;
if(r-l<0.001){
break;
}
for (int i = 0; i < month; i++) {
t=t*(1+mid)-pay;
}
if(t>0){
r=mid;
}
else if(t<0){
l=mid;
}
else{
printf("%.1f",mid*100);
}
} printf("%.1f",mid*100);
}