Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7973213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:03:03+00:00 2026-06-04T08:03:03+00:00

The following is the problem from Interviewstreet Can someone please give me a few

  • 0

The following is the problem from Interviewstreet Can someone please give me a few test cases along with the output. My solution is within the time limit for all test cases but is giving Wrong Answer.

Circle Summation (30 Points)

There are N children sitting along a circle, numbered 1,2,...,N clockwise. The ith child has a piece of paper with number ai written on it. They play the following game:

In the first round, the child numbered x adds to his number the sum of the numbers of his neighbors.

In the second round, the child next in clockwise order adds to his number the sum of the numbers of his neighbors, and so on.

The game ends after M rounds have been played.

Input:
The first line contains T, the number of test cases. T cases follow. The first line for a test case contains two space seperated integers N and M. The next line contains N integers, the ith number being ai.

Output:
For each test case, output N lines each having N integers. The jth integer on the ith line contains the number that the jth child ends up with if the game starts with child i playing the first round. Output a blank line after each test case except the last one. Since the numbers can be really huge, output them modulo 1000000007.

Constraints:

1 <= T <= 15
3 <= N <= 50
1 <= M <= 10^9
1 <= ai <= 10^9

Sample Input:

2
5 1
10 20 30 40 50
3 4
1 2 1

Sample Output:

80 20 30 40 50
10 60 30 40 50
10 20 90 40 50
10 20 30 120 50
10 20 30 40 100



23 7 12
11 21 6
7 13 24 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:03:05+00:00Added an answer on June 4, 2026 at 8:03 am

    If it seems to do ok for small test-cases, but not all, I would guess you have an overflow problem.

    Make sure you either…

    • Do the modulus after each addition, not just after adding all three numbers.
    • Use 64-bit numbers. This would still require modulus, but not as often.

    1000000007 is pretty close to the limit of signed 32-bit numbers (214748367). You can add to modulated numbers without overflow, but not three.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am new to iPhone programming..can anybody help me out from the following problem
Here is my problem: from the following XML that is within a column, I
I have a following problem. I am executing an OS command line from within
I have been working on the following problem from this book . A certain
I have a problem following from my previous problem . I also have the
I have the following problem: I have to run commands on remote servers from
I have the following problem: I opened the activity A, from which I opened
This problem follows on from a previous question . When I run the following
Following from these question Subset sum problem and Sum-subset with a fixed subset size
Following on from a question I posted yesterday about GUIs, I have another problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.