CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » October 2009 (Contest IX) » Just a simple sum

Just a simple sum

Problem code: H4

  • All Submissions

All submissions for this problem are available.

Given n and m, calculate 11 + 22 + 33 + ... + nn modulo m.

Input

The first line contains 1 ? t ? 10, the number of test cases. Then the test case definitions follow. Each test case is of the form: 1 ? n ? 1018, 1 ? m ? 200000

Output

For each test case simply write a single line containing the answer to the problem.

Example

Input:
6
1 100000
2 100000
3 100000
4 100000
5 100000
6 100000

Output:
1
5
32
288
3413
50069


Author: admin
Date Added: 15-09-2009
Time Limit: 10 - 80 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

Sorry for the last post. I

ACRush @ 1 Oct 2009 03:29 PM

Sorry for the last post. I misuse this tool. I just want to submit the code. For admin, could you please delete the previous post? I do sorry about that.

After submitting, it is

sid_chilling @ 1 Oct 2009 06:57 PM

After submitting, it is taking unusually long to show the result... Is anything wrong?

The time limit for this

admin @ 1 Oct 2009 07:05 PM

The time limit for this problem is 80 seconds. :)

My program's working

sunnyarpit123 @ 1 Oct 2009 08:29 PM

My program's working perfectly in Dev C++..but on submitting a runtime error occurs...why??!!!!  T_T :(

Itested the sample inputs on

muthukswamy @ 1 Oct 2009 10:25 PM

Itested the sample inputs on my program. Its perfectly displaying the output as intended. But still it shows wrong answer. Is there anything else that I have to check?

Please read the FAQ and

admin @ 1 Oct 2009 11:15 PM

Please read the FAQ and www.codechef.com/wiki

I believe something is wrong

neal @ 2 Oct 2009 01:16 AM

I believe something is wrong with the test data.

I too think there is

balakrishnan_v @ 2 Oct 2009 06:04 AM

I too think there is something wrong with the test data. Can the admins confirm the sanctity of the testset

I may very well be wrong, but

ashutoshmehra @ 2 Oct 2009 10:28 AM

I may very well be wrong, but I agree with Neil and Balakrishnan -- something seems amiss with the program checker/testcases.

But then again, one person _has_ managed to solve the problem....

I also agree with Neal,

ACRush @ 2 Oct 2009 10:51 AM

I also agree with Neal, Balakrishnan and Ashutosh, there is something wrong with the testcases.

We are checking the test

admin @ 2 Oct 2009 11:46 AM

We are checking the test data. Will post an update here as soon as we reach a conclusion :)

IS IOSTREAM.H NOT INCLUDED IN

ssp @ 2 Oct 2009 12:41 PM
IS IOSTREAM.H NOT INCLUDED IN GCC ?

Please take a look at FAQ and

admin @ 2 Oct 2009 12:52 PM

Please take a look at FAQ and Sample Solutions

IN SAMPLE SOLUTION THEY HAVE

ssp @ 2 Oct 2009 01:00 PM

IN SAMPLE SOLUTION THEY HAVE USED #INCLUDE<IOSTREAM> , SHOULDN'T IT BE <IOSTREAM.H>. BECAUSE MY COMPILER SAY'S FORMER IS WRONG.

ALSO CANT I USE MATH.H?

ssp @ 2 Oct 2009 01:07 PM

ALSO CANT I USE MATH.H?

The compiler we use is

admin @ 2 Oct 2009 01:13 PM

The compiler we use is mentioned in the FAQ and on www.codechef.com/wiki. Probably the compiler you are using does not comply with the c++ standards.

"We are checking the test

konvulooshun @ 2 Oct 2009 02:04 PM

"We are checking the test data. Will post an update here as soon as we reach a conclusion "

is test data right?

 

I can't comment on that yet

admin @ 2 Oct 2009 02:08 PM

I can't comment on that yet :)

This is not good here my

sumeetkumar001 @ 2 Oct 2009 05:52 PM

This is not good here my program is running but in ur simluation it's giving compile error....

i'm fed up now

Please check out the FAQ and

admin @ 2 Oct 2009 06:03 PM

Please check out the FAQ and www.codechef.com/wiki

Any update on the

vasanth204 @ 2 Oct 2009 07:15 PM
Any update on the below?
divyanshu ranjan - 2nd Oct,2009 14:04:43.

"We are checking the test data. Will post an update here as soon as we reach a conclusion "

is test data right?

Can you provide the test

vasanth204 @ 2 Oct 2009 07:16 PM

Can you provide the test cases so we can run on our own before submitting. please provide output as well.

Of course not, then you could

triplem @ 3 Oct 2009 03:39 AM

Of course not, then you could just submit hardcoded output.. you have to solve the problem by yourself without any help.

I reviewed some solutions

izulin @ 3 Oct 2009 04:29 PM

I reviewed some solutions (especially ACRush's) and my solution. Well, shame on you, I still claim testcases are correct.

but I'm still reviewing

izulin @ 3 Oct 2009 04:37 PM

but I'm still reviewing solutions and making extensive tests.

ha, found a bug, rejudge in

izulin @ 3 Oct 2009 04:54 PM

ha, found a bug, rejudge in progress (extremely specific bug..)

@Ashutosh Mehra The one

izulin @ 3 Oct 2009 07:09 PM

@Ashutosh Mehra

The one person simply reproduced my bug :>

Could you tell me how much

thatguypulkit @ 4 Oct 2009 01:11 AM

Could you tell me how much memory I can use for this or for that matter any problem in general at code chef?

Please read the FAQ

admin @ 4 Oct 2009 06:37 PM

Please read the FAQ

it showing NZEC error what is

robinsingh @ 5 Oct 2009 03:55 AM

it showing NZEC error what is that?

@robinsingh: NZEC would mean

ashutoshmehra @ 5 Oct 2009 08:43 AM

@robinsingh: NZEC would mean that your program is returning a non-zero value to the environment. In C programs, you should do a "return 0" from your main function. See the forum thread: http://discussed.codechef.com/showthread.php?t=34

The time limit seems to be

vinaysingh @ 5 Oct 2009 07:25 PM

The time limit seems to be misleading to me. Are you saying our program should be able to handle just 10 test cases in 80 second? Or is the the program run multiple times with different set of inputs ?

Both are true. You should

admin @ 5 Oct 2009 09:37 PM

Both are true. You should handle all 10 test cases in 80 seconds. There might be multiple test files each containing a maximum of 10 test cases.

pls give some discussion on

dabbcomputers @ 5 Oct 2009 10:39 PM
pls give some discussion on output

what is SIGARBT error

robinsingh @ 7 Oct 2009 12:48 AM

what is SIGARBT error

Please read the FAQ and

admin @ 7 Oct 2009 02:08 PM

Please read the FAQ and www.codechef.com/wiki

on submitting i get runtime

aliasnikhil @ 7 Oct 2009 11:02 PM
on submitting i get runtime error though my program works fine. please help

I am able to solve data

sumit9 @ 7 Oct 2009 11:11 PM

I am able to solve data values like (N = 1o^18 , M= 199999) which should take max time, in nearly 10 s. But still I am getting TLE. Please help. I feel my algo is optimized already  :(

The specs of the server might

admin @ 7 Oct 2009 11:24 PM

The specs of the server might be different from those of your machine. Check out www.codechef.com/wiki for more information about the specifications of our servers.

 

my programm getting Runtime

darkCloud @ 8 Oct 2009 03:48 PM

my programm getting Runtime Error (NZEC).

m nt getting that how my program is returning a non-zero value to the environment.

admin can u plz help me.

 

 

hey guiz the input can be to

marutinaidu @ 8 Oct 2009 11:42 PM

hey guiz the input can be to big as 10^18

how is the input given

to administrator input can be

marutinaidu @ 8 Oct 2009 11:44 PM

to administrator

input can be to big as 10^18

how is the input given i mean wil they type 998746754345354363 like that

Yes.

admin @ 9 Oct 2009 01:50 PM

Yes.

Is the time limit really 80

braineater @ 10 Oct 2009 07:00 PM

Is the time limit really 80 sec? My solution works locally in 0.5 seconds for the worst case (per test case), but I'm getting TLE.

Yes, the time is 80 seconds.

admin @ 10 Oct 2009 09:07 PM

Yes, the time is 80 seconds.

when will the submissions for

haptork @ 12 Oct 2009 05:38 PM

when will the submissions for the problem will again get accepted.

Check

admin @ 12 Oct 2009 06:29 PM

Check www.codechef.com/problems/H4

can i submit my code to this

raj62esh @ 27 Oct 2009 06:57 PM

can i submit my code to this prob now.......

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com