What's the problem...
Output is okay for the test cases..
But wrong answer!!
Where's the bug ?
Help me to find it out..
Thanks in advance..
Here's my code...
#include<iostream>
#include<math.h>
using namespace std;
int main(void)
{
int t,c=1;
unsigned long long n,k,mod,w,i,sum,f,ans;
cin>>t;
while(t--)
{
cin>>n>>k>>mod;
f=(k*pow(n,k-1));
w=f%mod;
ans=0;
for(i=0; i<n; i++)
{
cin>>sum;
ans+=(sum*f%mod)%mod;
}
cout <<"Case " <<c++ <<": " <<ans <<endl;
}
return 0;
}
11718 - Fantasy of a Summation
Moderator: Board moderators
11718 - Fantasy of a Summation
i Quit for a fresher start
Re: 11718 - Fantasy of a Summation
pow() will not work
P.S Use code tags.
P.S Use code tags.
Ami ekhono shopno dekhi...
HomePage
HomePage
-
- New poster
- Posts: 15
- Joined: Thu Jul 08, 2010 8:28 am
Re: 11718 - Fantasy of a Summation
use repeated squaring algorithm instead of pow ........
hope it helps ....
Anis
hope it helps ....
Anis