Created
March 14, 2021 08:10
-
-
Save devgenjin77/963b9decb6b8077b5c6691082e568e94 to your computer and use it in GitHub Desktop.
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
static long solve(long n){ | |
if(n < 1000){ | |
return 0; | |
} | |
long ans = 0; | |
if(n >= 1_000_000_000_000_000l){ | |
ans += 5; | |
} | |
if(n >= 1_000_000_000_000l){ | |
ans += (Math.min(1_000_000_000_000_000l - 1, n) - (1_000_000_000_000l - 1)) * 4; | |
} | |
if(n >= 1_000_000_000l){ | |
ans += (Math.min(1_000_000_000_000l - 1, n) - (1_000_000_000l - 1)) * 3; | |
} | |
if(n >= 1_000_000l){ | |
ans += (Math.min(1_000_000_000l - 1, n) - (1_000_000l - 1)) * 2; | |
} | |
if(n >= 1_000l){ | |
ans += (Math.min(1_000_000l - 1, n) - (1_000l - 1)) * 1; | |
} | |
return ans; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment