tgamma function
Hello!I'm trying to use the tgamma function to solve this problem :
https://www.hackerearth.com/may-easy-challenge-15/algorithm/panda-and-chain-reaction/. But I get it wrong every time. Although the example works, some numbers become negative. Can you help me?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
long long t,n,x,i,l;
cin>>t;
for(i=1;i<=t;i++)
{cin>>n;
cin>>x;
x=x%1000003;
l=tgamma(n+1);
l=l%100003;
x=x*l;
cout<<x%1000003<<"\n";
}
return 0;
}
|
Topic archived. No new replies allowed.