ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1370. Magician

Why this crashes on test #2 ?
Posted by Black^n^White 6 Jan 2007 21:12
I can't understand what's wrong with this C++ code:

unsigned n, m, index = 0;
cin >> n >> m;

char *seq = new char[n];

for(int i = 0; i < n; ++i)
cin >> seq[i];

for(int i = m; i < n; ++i)
cout << seq[i];

for(int i = n-m; i < 10; ++i)
cout << seq[index++];
Idea
Posted by Alexander Prokazyuk (TKTL) 7 Jan 2007 19:17
You can take reminder (n%m) and write numbers from reminder+1 until 10.
Re: Why this crashes on test #2 ?
Posted by enick 5 Apr 2008 23:18
For example,use my AC code(C)

#include <stdio.h>
int N,M;
int a[1000];
int i,j,z;
int main()
{
scanf("%d%d",&N,&M);
for (i=0;i<N;i++)
{
scanf("%d",&a[i]);
}
z=M%N;
N--;
j=z;
i=0;
while (i<10)
{
printf("%d",a[z]);
if (z==N)
z=0;
else z++;

i++;

}
printf("\n");
return 0;
}