Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

PS 부수기

Project Euler #686 : Powers of Two 본문

Project Euler

Project Euler #686 : Powers of Two

jyheo98 2021. 9. 13. 22:18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int main() {
    IOS;
    long double x = 2;
    int cnt=0;
    for(long double k=0 ; ; k++) {
        long double l=(k+log10(123))/(log10(2));
        long double r=(k+log10(124))/(log10(2));
        int il = (int)l+1;
        int ir = (int)r;
        for(int t=il;t<=ir;t++) {
            cnt++
            if(cnt==678910) {
                debug(t);            
            }
        }
    }
}
cs

 

풀이

$2^x = 123xyz..$

$xlog2=log(123.xyz.... \times 10^k)$

          $=k + log(123.xyz....)$

 

$k+log123 \leq xlog2 \leq k+log124$

 

$k \geq 0$마다 조건을 만족하는 자연수 $x$를 찾으면 된다.

실행시간 9s

 

Comments