modify code

master
algorithmzuo 3 years ago
parent 708e3f79eb
commit 55ac6b6aec

@ -59,12 +59,8 @@ public class Code04_NthDigit {
if (offset == 0) { if (offset == 0) {
return (path / help[nth]) % 10; return (path / help[nth]) % 10;
} else { } else {
int cur = offset == all ? 1 : 0; int j = (nth - 1) / (len * offset);
int j = nth / (len * offset); int cur = (offset == all ? 1 : 0) + j;
if (nth % (len * offset) == 0) {
j--;
}
cur += j;
return number(cur * (all / offset) + path, len, offset / 10, all, nth - j * len * offset); return number(cur * (all / offset) + path, len, offset / 10, all, nth - j * len * offset);
} }
} }

Loading…
Cancel
Save