11718 - Fantasy of a Summation

All about problems in Volume 117. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
User avatar
Psh
New poster
Posts: 7
Joined: Tue Jul 06, 2010 9:52 pm
Location: Bangladesh
Contact:

11718 - Fantasy of a Summation

Post by Psh » Tue Jul 13, 2010 11:24 pm

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;
}
i Quit for a fresher start

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Re: 11718 - Fantasy of a Summation

Post by Jan » Wed Jul 14, 2010 12:14 pm

pow() will not work

P.S Use code tags.
Ami ekhono shopno dekhi...
HomePage

anis_cuet016
New poster
Posts: 15
Joined: Thu Jul 08, 2010 8:28 am

Re: 11718 - Fantasy of a Summation

Post by anis_cuet016 » Tue Aug 03, 2010 4:02 am

use repeated squaring algorithm instead of pow ........
hope it helps ....

Anis

Post Reply

Return to “Volume 117 (11700-11799)”