Mixa_01's blog

By Mixa_01, history, 5 months ago, In English

here is my code:

include <bits/stdc++.h>

using namespace std;

int main() { double a,b; double sum=0;

cin >> a>>b;

sum = pow(a,b)-pow(b,a); cout << sum<< endl; return 0; }

why it is showing wrong answer on test 5 no matter whay i do.

question: You are given natural numbers a and b. Find ab-ba.

Input

Input contains numbers a and b (1≤a,b≤100).

Output

Write answer to output.

Sample Input

2 3

Sample Output

-1

  • Vote: I like it
  • -3
  • Vote: I do not like it

»
5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Consider the input 99 100. Note that both pow(99, 100) and pow(100, 99) will overflow the limits of int or even long long int in C++. So you could solve this problem using big integers. For example, in python you can simply submit:

a, b = map(int, input().split())

print(a**b - b**a)