EASYFACT - Easy Factorials
Finding factorials are easy but they become large quickly that is why Lucky hate factorials. Today he have another task related to factorials.
For a given number n how many ways factorial n can expressed as a sum of two or more consecutive positive integers. Can you help lucky ?
Input
First line contains single integer T < 5001, next T lines followed by an integer N<10^8 and M<10^9.
where M is a prime number.
Output
Print the desired result mod M.
Example
Input: 1 3 7 Output: 1
Explanation:: 3! = 1+2+3 only one way.
Speed Adicts My best time for all cases is 1.57s. Best of Luck have fun:) .
hide comments
varun bumb:
2015-08-09 00:02:33
@Lakshman,can you please check my code.id = 14852186.
|
|
Vivek Mangal:
2015-07-08 15:09:02
@admin i am beginner.can u pls check my code.id=14625920.
|
|
Soma:
2015-07-04 02:14:26
@[Lakshman] : can you check my code and tell me what other optimisations i can make in the code. my code now runs in 3.25s but your able to solve it even faster (as your note at the end says). code id :14596189
|
|
saksham agrawal:
2015-06-22 19:20:54
@admin..Please help.. do check my code..
|
|
Marko Puza:
2015-06-15 01:35:26
Very nice problem.
|
|
black MaMbA:
2015-06-14 09:31:42
@Lakhsman,would you please tell me if my approach is correct or not
|
|
Akashdeep Goel:
2015-06-13 12:53:44
@admin:- Please check whether my approach is correct and also how many test cases i am failing..:-(
|
|
[Lakshman]:
2015-06-12 11:54:11
@ADITYA PRAKASH Based on submission 14436796 Your code works fine for small cases but RTE in large one. |
|
ADITYA PRAKASH:
2015-06-11 20:04:01
@admin is my approach correct? |
|
gamer496:
2015-06-11 01:03:15
@admin is my approach correct?
|
Added by: | [Lakshman] |
Date: | 2015-05-13 |
Time limit: | 5s-10s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 JS-MONKEY |