112. a^b-b^a - Codeforces || You are given natural numbers a and b. Find a^b-b^a. Codeforces
112. a^b-b^a https://codeforces.com/problemsets/acmsguru/problem/99999/112 time limit per test: 0.25 sec. memory limit per test: 4096 KB You are given natural numbers a and b. Find a^b-b^a. Input Input contains numbers a and b (1≤a,b≤100). Output Write answer to output. Sample Input 2 3 Sample Output -1 Solution Code: C++ #include <iostream> #include <cmath> // solved the problem but not accepted with this code... // i got accepted with the python code. int main () { int a, b; std::cin >> a >> b; long long pa = pow (a, b); long long pb = pow (b, a); std::cout << pa - pb << std::endl; return 0 ; } Solution Code: Python 3 # Accepted a,b = map ( int , input ().split()) pa = pow (a,b) pb = pow (b,a) print (pa - pb)