Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <cmath>
  4.  
  5. #define ll long long
  6.  
  7. using namespace std;
  8.  
  9. map<string, double> m;
  10.  
  11. int main(void) {
  12. ios_base::sync_with_stdio(false);
  13.  
  14. int parties, guesses;
  15.  
  16. cin >> parties >> guesses;
  17. for(int i = 0; i < parties; i++) {
  18. string str;
  19. cin >> str;
  20.  
  21. double d;
  22. cin >> d;
  23.  
  24. m[str] = d;
  25. }
  26.  
  27. for(int i = 1; i <= guesses; i++) {
  28. double ans_double = 0.0;
  29. ll ans_int = 0;
  30.  
  31. string lixo;
  32. while(true) {
  33. string id;
  34. cin >> id;
  35.  
  36. ans_double += m[id];
  37.  
  38. cin >> lixo;
  39.  
  40. if(lixo != "+") {
  41. break;
  42. }
  43. }
  44. ans_double *= 10.0;
  45. ans_int = round(ans_double);
  46.  
  47. double given_ans = 0.0;
  48. cin >> given_ans;
  49. given_ans *= 10.0;
  50.  
  51. ll given_ans_int = round(given_ans);
  52.  
  53. int DEU_BOM = 0;
  54. if(lixo == "<")
  55. DEU_BOM = ans_int < given_ans_int;
  56. else if(lixo == "<=")
  57. DEU_BOM = ans_int <= given_ans_int;
  58. else if(lixo == ">")
  59. DEU_BOM = ans_int > given_ans_int;
  60. else if(lixo == ">=")
  61. DEU_BOM = ans_int >= given_ans_int;
  62. else
  63. DEU_BOM = ans_int == given_ans_int;
  64.  
  65. cout << "Guess #" << i << " was ";
  66. (!DEU_BOM) ? cout << "incorrect." : cout << "correct.";
  67. cout << '\n';
  68. }
  69.  
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement