378A - Playing with Dice - CodeForces Solution


brute force *800

Please click on ads to support us..

Python Code:

from collections import defaultdict
import random

a, b = list(map(int, input().split()))
q=[0,0,0]
for i in range(1,7):
    if abs(a-i)>abs(b-i):
        q[2]+=1
    elif abs(a-i)==abs(b-i):
        q[1]+=1
    else:
        q[0]+=1
print(*q)

C++ Code:

// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    int a1 = 0, d = 0, b1 = 0;
    for (int i = 1; i <= 6; i++)
    {
        if (abs(i - a) < abs(i - b))
        {
            a1++;
        }
        else if (abs(i - a) > abs(i - b))
        {
            b1++;
        }
        else
        {
            d++;
        }
    }
    cout << a1 << " " << d << " " << b1 << endl;

    return 0;
}


Comments

Submit
0 Comments
More Questions

84. Largest Rectangle in Histogram
60. Permutation Sequence
42. Trapping Rain Water
32. Longest Valid Parentheses
Cutting a material
Bubble Sort
Number of triangles
AND path in a binary tree
Factorial equations
Removal of vertices
Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship