fork download
  1. // D (run time)
  2. // $ dmd -O -version=Runtime -run C.d > out.txt
  3. import std.array;
  4. import std.conv;
  5. import std.string;
  6.  
  7. string solveAll(string s)
  8. {
  9. return s.splitLines().solveEach(1);
  10. }
  11.  
  12. string solveEach(string[] lines, int i)
  13. {
  14. if( i == lines.length )
  15. return "";
  16.  
  17. // std.algorithm.map doesn't work in compile time yet.
  18. int[] t;
  19. foreach(s; lines[i].split())
  20. t ~= s.to!int();
  21. return text("Case #", i, ": ", solve(t[0], t[1]), "\n", lines.solveEach(i+1));
  22. }
  23.  
  24. int solve(int A, int B)
  25. {
  26. int cnt = 0;
  27. foreach(x; A..B+1)
  28. {
  29. bool[int] used;
  30.  
  31. string xs = x.text();
  32. foreach(i; 1..xs.length) {
  33. int y = (xs[i..$] ~ xs[0..i]).to!int();
  34. if( x<y && y<=B )
  35. used[y] = true;
  36. }
  37. cnt += used.length;
  38. }
  39. return cnt;
  40. }
  41.  
  42. immutable inputFileName = "C.in";
  43.  
  44. version(RunTime)
  45. {
  46. import std.file, std.stdio;
  47. void main() { inputFileName.readText().solveAll().write(); }
  48. }
  49. else
  50. {
  51. pragma(msg, import(inputFileName).solveAll());
  52. }
  53.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty