1519B - The Cake Is a Lie - CodeForces Solution


dp math *800

Please click on ads to support us..

Python Code:

inp1 = int(input())
for i in range(inp1):
    a,b,c = input().split()
    a = int(a);b = int(b);c = int(c)
    MT = [[i for i in range(a+1)] for i in range(b+1)]
    MT[-1][-1]=a*b-1
    if MT[-1][-1] == c:
        print("YES")
    else:
        print("NO")

C++ Code:

#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    int t;
    cin >> t;
    for (int i = 0; i < t; i++){
        int n, m, k;
        cin >> n >> m >> k;
        int count = 0;
        count += (m - 1);
        count += (n - 1) * m;
        if (count == k){
            cout << "YES" << "\n";
        }
        else{
            cout << "NO" << "\n";
        }
    }
}


Comments

Submit
0 Comments
More Questions

1220B - Multiplication Table
1644A - Doors and Keys
1644B - Anti-Fibonacci Permutation
1610A - Anti Light's Cell Guessing
349B - Color the Fence
144A - Arrival of the General
1106A - Lunar New Year and Cross Counting
58A - Chat room
230A - Dragons
200B - Drinks
13A - Numbers
129A - Cookies
1367B - Even Array
136A - Presents
1450A - Avoid Trygub
327A - Flipping Game
411A - Password Check
1520C - Not Adjacent Matrix
1538B - Friends and Candies
580A - Kefa and First Steps
1038B - Non-Coprime Partition
43A - Football
50A - Domino piling
479A - Expression
1480A - Yet Another String Game
1216C - White Sheet
1648A - Weird Sum
427A - Police Recruits
535A - Tavas and Nafas
581A - Vasya the Hipster