Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*------------------- DIE ROLL -------------------*/
- #include <iostream>
- #include <iomanip>
- #include <map>
- using namespace std;
- map<float, string> fraction =
- {
- {6.0/6.0, "1/1"},
- {5.0/6.0, "5/6"},
- {4.0/6.0, "2/3"},
- {3.0/6.0, "1/2"},
- {2.0/6.0, "1/3"},
- {1.0/6.0, "1/6"}
- };
- int main()
- {
- int max_dice_num = 6;
- int y, w;
- cin >> y >> w;
- if (y == 1 && w == 1)
- {
- cout << "1/1";
- return 0;
- }
- int max_points = y > w? y : w;
- int cant_possible_points = max_dice_num - max_points + 1;
- // cout << cant_possible_points << " ";
- // cout << max_dice_num << " ";
- string prob = fraction[(float)cant_possible_points / (float)max_dice_num];
- //string prob = fraction[(3.0 / 6.0)];
- //cout << fixed << setprecision(2) << prob;
- cout << prob;
- return 0;
- }
- /*------------------- FIN DIE ROLL -------------------*/
- /*------------------- TRIANGULAR NUMBERS -------------------*/
- #include <iostream>
- using namespace std;
- int main()
- {
- /*
- Me voy fijando si el número de input es igual a la suma de todos los números (empezando desde 1) hasta n,
- empezando con n = 1. Si es igual imprimo YES, si supero el número imprimo NO.
- */
- int input_num;
- cin >> input_num;
- if(input_num == 0 || input_num == 1)
- {
- cout << "YES";
- return 0;
- }
- long long sum = 3;
- int i = 1;
- while(sum < input_num)
- {
- sum = (i * (i + 1)) / 2;
- i++;
- }
- if(input_num == sum)
- {
- cout << "YES";
- } else
- {
- cout << "NO";
- }
- return 0;
- }
- /*------------------- FIN TRIANGULAR NUMBERS -------------------*/
- /*------------------- DOMINO PILING -------------------*/
- #include <iostream>
- using namespace std;
- int main()
- {
- int m, n;
- cin >> m >> n;
- cout << (m*n)/2;
- return 0;
- }
- /*------------------- FIN DOMINO PILING -------------------*/
- /*------------------- BLACKJACK -------------------*/
- #include <iostream>
- #include <map>
- using namespace std;
- map<int, int> values =
- {
- {1, 4},
- {2, 4},
- {3, 4},
- {4, 4},
- {5, 4},
- {6, 4},
- {7, 4},
- {8, 4},
- {9, 4},
- {10, 15},
- {11, 4}
- };
- int main()
- {
- int points;
- cin >> points;
- if(points < 11)
- {
- cout << 0;
- return 0;
- }
- cout << values[points - 10];
- return 0;
- }
- /*------------------- FIN BLACKJACK -------------------*/
- /*------------------- PLAYING WITH DICE -------------------*/
- #include <iostream>
- using namespace std;
- int main()
- {
- int a, b;
- cin >> a >> b;
- int a_wins = 0, draw = 0, b_wins = 0;
- int a_dist = 0, b_dist = 0, dif = 0;
- for (int i = 1; i <= 6; i++)
- {
- a_dist = abs(a - i);
- b_dist = abs(b - i);
- dif = a_dist - b_dist;
- if (dif < 0)
- {
- a_wins++;
- } else if(dif > 0)
- {
- b_wins++;
- } else
- {
- draw++;
- }
- }
- cout << a_wins << " " << draw << " " << b_wins;
- return 0;
- }
- /*------------------- FIN PLAYING WITH DICE -------------------*/
Add Comment
Please, Sign In to add comment