Help me find error in this code

Problem link: https://codeforces.com/problemsets/acmsguru/problem/99999/112

#include<bits/stdc++.h>
#define f(i,a,b) for(int i=a;i<b;i++)
#define dbg(x); cout<<"\n"<<#x<<": "<<x<<"\n";
#define ret return
using namespace std;
int main(){ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int a,b,ans;
	cin>>a>>b; 
	ans=pow(a,b)-pow(b,a);
	cout<<ans<<"\n";
	ret 0; 
}       

I am getting the wrong answer in test 5 I don’t why?

a and b could be up to 100.
Therefore a^b or b^a will not fit into a integer or even into a long long.

3 Likes

then?

You can use Python instead.:slightly_smiling_face:
(a** b) - (b**a)

1 Like

You might need to use vectors or arrays in cpp.
Have you tried this question https://www.codechef.com/problems/FCTRL2/

1 Like

The input can be upto 100… 100^100 can also be one test case

1 Like

yes i have tried