fork download
  1. n <- 5000
  2. s <- cumsum((n - 1) : 1)
  3. d <- dist((1:n) ^ 3)
  4. r <- rle(sort(d[duplicated(d)]))
  5.  
  6. for (x in r$value[r$length >= 4]) {
  7. i <- which(d == x)
  8. b <- findInterval(i, s, left.open = TRUE) + 1
  9. a <- i - s[b - 1] + b
  10. cat(x, ": ", toString(sprintf("(%d, %d)", a, b)), "\n", sep = "")
  11. }
Success #stdin #stdout 1.62s 323404KB
stdin
Standard input is empty
stdout
1412774811: (1134, 357), (1155, 504), (1246, 805), (2115, 2004), (4746, 4725)