8000 Update 1456.cpp · sihyeon-kim/basic-algo-lecture@2f772b7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f772b7

Browse files
Update 1456.cpp
1 parent 2561c18 commit 2f772b7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

0x12/solutions/1456.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,9 @@ int main(void) {
3232
}
3333
cout << cnt;
3434
}
35+
/*
36+
p가 10^7 언저리이면 p^2는 a와 b 사이이나 p^3이 long long 범위를 벗어날 수 있다.
37+
integer overflow 방지를 위해 i = p, p^2, p^3, ... 으로 두고 이 때 i*p가 거의 소수인데
38+
i <= b / p 이 아니면(i*p <= b가 아니면) break를 하는 방식을 사용해 i*p를 계산할 때
39+
overflow가 발생하지 않도록 한다.
40+
*/

0 commit comments

Comments
 (0)
0