Algorithm
Problem Name: beecrowd | 1007
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1007?origem=1
Algorithm:
((A * B) - (C * D))
Problem Detail: beecrowd | 1007
Difference
Adapted by Neilor Tonin, URI Brazil
Read four integer values named A, B, C and D. Calculate and print the difference of product A and B by the product of C and D (A * B - C * D).
Input
The input file contains 4 integer values.
Output
Print DIFERENCA (DIFFERENCE in Portuguese) with all the capital letters, according to the following example, with a blank space before and after the equal signal.
Input Samples | Output Samples |
5 |
DIFERENCA = -26 |
0 |
DIFERENCA = -56 |
5 |
DIFERENCA = 86 |
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include <stdio.h>
int main() {
int A , B , C , D, difference;
scanf("%d %d %d %d", &A , &B ,&C, &D);
difference=((A * B) - (C * D));
printf("DIFERENCA = %d\n", difference);
return 0;
}
Copy The Code &
Try With Live Editor
Input
6
7
8
Output
#2 Code Example with C++ Programming
Code -
C++ Programming
#include <stdio.h>
int main() {
int A , B , C , D, difference;
scanf("%d %d %d %d", &A , &B ,&C, &D);
difference=((A * B) - (C * D));
printf("DIFERENCA = %d\n", difference);
return 0;
}
Copy The Code &
Try With Live Editor
Input
0
7
8
Output
#3 Code Example with Java Programming
Code -
Java Programming
import java.util.Scanner;
public class Main {
public static void main(String[] args){
int A , B , C , D, difference;
Scanner sc = new Scanner(System.in);
A = sc.nextInt();
B = sc.nextInt();
C = sc.nextInt();
D = sc.nextInt();
difference=((A * B) - (C * D));
System.out.printf("DIFERENCA = %d\n", difference);
}
}
Copy The Code &
Try With Live Editor
Input
0
7
8
Output
#4 Code Example with Python Programming
Code -
Python Programming
a= int(input())
b= int(input())
c= int(input())
d= int(input())
difference=((a * b) - (c * d))
print("DIFERENCA = %d" %difference)
Copy The Code &
Try With Live Editor
Input
6
-7
8
Output
#5 Code Example with C# Programming
Code -
C# Programming
using System;
class URI {
static void Main(string[] args) {
int a, b, c, d, difference;
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
c = Convert.ToInt32(Console.ReadLine());
d = Convert.ToInt32(Console.ReadLine());
difference = ((a * b) - (c * d));
Console.WriteLine("DIFERENCA = " + difference);
Console.ReadKey();
}
}
Copy The Code &
Try With Live Editor
Input
6
-7
8
Output
Demonstration
#1007 Beecrowd Online Judge Solution 1007 Solution C, C++, Java, Python