Skip to content

Commit 4545963

Browse files
committed
Fix bug
1 parent c416f77 commit 4545963

File tree

1 file changed

+7
-13
lines changed
  • Codeforces/Round629_div3

1 file changed

+7
-13
lines changed

Codeforces/Round629_div3/B.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,11 @@
1818
using namespace std;
1919
using ll = long long;
2020

21-
double newton(int n, int k) {
22-
double x0 = 0;
23-
double y0 = pow(x0, 2) - x0 - 2 * k;
24-
double dx;
25-
double b;
26-
27-
for (int i = 0; i < 100; ++i) {
28-
dx = 2 * k - 1;
29-
b = y0 - dx * x0;
30-
x0 = -b / dx;
31-
y0 = pow(x0, 2) - x0 - 2 * k;
21+
double newton(ll n, ll k) {
22+
double x0 = 5;
23+
24+
for (int i = 0; i < 25; ++i) {
25+
x0 -= (pow(x0, 2) - x0 - 2 * k) / (2 * x0 - 1);
3226
}
3327

3428
ll temp;
@@ -41,7 +35,7 @@ double newton(int n, int k) {
4135
return x0;
4236
}
4337

44-
string solve(int n, int k) {
38+
string solve(int n, ll k) {
4539
double root = newton(n, k);
4640
ll first = floor(root);
4741

@@ -76,7 +70,7 @@ int main() {
7670

7771
int T = 0;
7872
cin >> T;
79-
int n, k;
73+
ll n, k;
8074
while (T--) {
8175
cin >> n >> k;
8276

0 commit comments

Comments
 (0)