Advertisement
steverobinson

Untitled

Mar 19th, 2011
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1.  
  2. 1. MAGIC SEQUENCE
  3.  
  4. The sequence is defined as follows The first five numbers of the sequence are the first five natural numbers respectively.(1,2,3,4,5). , From then the nth term is the sum of its n%5+1 preceding terms . For example term39 is the sum of 39%5+1=5 preceding five terms (t38+t37+t36+t35+t34) .
  5.  
  6. INPUT FORMAT
  7.  
  8. The input will be an integer in the first line denoting the number(t) of test cases (at most five). From the next line there follow t lines containing three numbers separated by spaces out of which the first two denote the indices of terms .You need to add all the terms starting from the first index to the last one in the above sequence and find out its mod with the third number . First two numbers lie between 1 & 30000000. The third number will be having at most 30 digits in it .
  9.  
  10. OUTPUT FORMAT
  11.  
  12. All you need to print is only the remainder for each test case in a new line.No new line at the end.
  13.  
  14. SAMPLE INPUT
  15.  
  16. 4
  17. 1 5 15
  18. 1 23 34
  19. 1 345 3948394875023947
  20. 12345 123456 10293847568765432109123857640
  21. SAMPLE OUTPUT
  22.  
  23. 0
  24. 6
  25. 244925775962101974
  26. 3248055569802838550909454360
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement