Skip to content

Instantly share code, notes, and snippets.

@regtan
Created May 10, 2012 11:11
Show Gist options
  • Save regtan/2652470 to your computer and use it in GitHub Desktop.
Save regtan/2652470 to your computer and use it in GitHub Desktop.
Gach
package org.kirino;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.math.random.RandomData;
import org.apache.commons.math.random.RandomDataImpl;
public class Gacha {
public static void main(String[] args) {
int types = Integer.valueOf(args[0]);
RandomData randomData = new RandomDataImpl();
Map<Integer, Integer> archive = new HashMap<Integer, Integer>();
int cnt = 0;
while (true) {
int result = randomData.nextInt(1, types);
archive.put(result, 1);
cnt++;
if (archive.size() == types) {
break;
}
}
System.out.println(cnt);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment