fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.  
  6. cout<<setprecision(2)<<fixed;
  7.  
  8. char c;
  9. cin>>c;
  10.  
  11. double initial;
  12. cin>>initial;
  13.  
  14.  
  15. map<char,double> mpp;
  16. mpp[c]=initial;
  17.  
  18. int n;
  19. cin>>n;
  20.  
  21. int skip;
  22. cin>>skip;
  23. for(int i=0;i<n;i++){
  24. char u,v;
  25. cin>>u>>v;
  26. int pt;
  27. cin>>pt;
  28. if(i==skip){
  29. continue;
  30. }
  31.  
  32.  
  33. double balance=mpp[u];
  34. double to_give = double(balance*pt)/(100.00);
  35. mpp[v]+=to_give;
  36. mpp[u]=balance-to_give;
  37.  
  38. }
  39.  
  40.  
  41. for(auto it:mpp){
  42. cout<<it.first<<" will have "<<it.second<<endl;
  43. }
  44.  
  45. return 0;
  46. }
Success #stdin #stdout 0.01s 5268KB
stdin
A 100
9
3
A B 20
A C 40
B D 30
C D 50 
C F 20
B E 50
D E 25 
F G 10
E C 50
stdout
A will have 48.00
B will have 7.00
C will have 29.85
D will have 4.50
E will have 4.25
F will have 5.76
G will have 0.64