i had done this if n value is 10 but not getting the answer why dut to large integer is there anything else
#include<bits/stdc++.h>
using namespace std;
unsigned long long int factorial(unsigned long long int n)
{
return (n==1 || n==0) ? 1: (n * factorial(n - 1))%1000000007;
}
int main(){
long long int t;
cin>>t;
while(t--){
long long int n,res=1;
cin>>n;
for(int i=2;i<=n;i++){
res=res*(pow(i,n-(i-1)));
res=(((((res%1000000007)%1000000007)%1000000007)%1000000007)%1000000007)%1000000007;
}
cout<<res%1000000007<<"\n";
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire