fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. public class Main
  6. {
  7. public static void main (String[] args)
  8. {
  9. Scanner in = new Scanner(System.in);
  10. Vector <String> c = new Vector <String>();
  11. String a = in.nextLine();
  12. for(int i=0;i<a.length();i++)
  13. {
  14. for(int j=i+1;j<=a.length();j++)
  15. {
  16. c.add(a.substring(i,j));
  17. }
  18. }
  19. HashSet<String> unique = new HashSet<String>(c);
  20. Vector<String> d = new Vector<String>(unique);
  21. System.out.print(d.size());
  22. }
  23. }
Success #stdin #stdout 0.12s 29456KB
stdin
ALPHABET
stdout
[A, B, BE, LP, ABE, ALP, LPH, PHABE, E, PHA, H, ALPHA, L, HABET, ABET, P, PHABET, T, HABE, LPHA, AB, LPHABET, HAB, AL, ALPHABET, ALPHABE, ET, BET, LPHAB, PH, LPHABE, HA, ALPHAB, PHAB, ALPH]35