Created
April 16, 2013 10:44
-
-
Save rohit-nsit08/5394983 to your computer and use it in GitHub Desktop.
topcoder : SRM 571 Div 1 Problem :250
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* @author rohit jangid | |
* @data Apr 16, 2013 | |
* @file-name FoxAndMp3.java | |
* @license this code is licensed under WTFPL V-2.0 | |
* @details Topcoder SRM 571 Div I problem 250 | |
*/ | |
import java.util.Arrays; | |
public class FoxAndMp3 { | |
public int calculate(int index, int t, int n, String[] play) { | |
int i = t; | |
while(i <= t + 9 && i <= n && index < 50) { | |
play[index++] = i + ".mp3"; | |
index = calculate(index, i*10, n, play); | |
i++; | |
} | |
return index; | |
} | |
public String[] playList(int n) { | |
String[] play = new String[50]; | |
int i = 1; | |
int index = 0; | |
while(i <= 9 && i <= n && index < 50) { | |
play[index++] = i + ".mp3"; | |
index = calculate(index, i*10,n,play); | |
i++; | |
} | |
if(n < 50) { | |
String[] playlist = new String[n]; | |
for(i =0; i<n; i++) { | |
playlist[i] = play[i]; | |
} | |
return playlist; | |
} | |
else return play; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment