diff options
author | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2017-03-01 19:27:53 +0700 |
---|---|---|
committer | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2017-03-01 19:27:53 +0700 |
commit | b76eee8ea94df8048f2a7ae901856a480a43e8aa (patch) | |
tree | b47668b4394a8724264aa26764c14e45e5b2a8ec /others/volume1/043.pas | |
parent | 1cfc8e7ba45619f8a9837b4438c609948800dfff (diff) | |
download | cp-b76eee8ea94df8048f2a7ae901856a480a43e8aa.tar.gz |
Update others/volume1
Diffstat (limited to 'others/volume1/043.pas')
-rw-r--r-- | others/volume1/043.pas | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/others/volume1/043.pas b/others/volume1/043.pas new file mode 100644 index 0000000..a7af017 --- /dev/null +++ b/others/volume1/043.pas @@ -0,0 +1,22 @@ +uses math; + +var + n, i, m: uint64; + +begin + readln(n); + n := n - 1; + i := 0; + while i < 18 do + begin + m := 9 * 10 ** i * (i + 1); + if m < n then + n := n - m + else + break; + i := i + 1 + end; + m := i - (n - 1) mod (i + 1); + n := 10 ** i + (n + i) div (i + 1) - 1; + writeln(n div 10 ** m mod 10) +end. |