ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1001. Reverse Root

C Accepted
Posted by vzhanm 28 Apr 2024 12:09
/* https://acm.timus.ru/problem.aspx?space=1&num=1001 */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/* #include <sys/queue.h> */
/*
*/
struct name {                                \
struct type *slh_first;    /* first element */            \
}

{ NULL }

#define    SLIST_ENTRY(type)                        \
struct {                                \
struct type *sle_next;    /* next element */            \
}

/*
*/
} while (/*CONSTCOND*/0)

#define    SLIST_INSERT_AFTER(slistelm, elm, field) do {            \
(elm)->field.sle_next = (slistelm)->field.sle_next;        \
(slistelm)->field.sle_next = (elm);                \
} while (/*CONSTCOND*/0)

} while (/*CONSTCOND*/0)

} while (/*CONSTCOND*/0)

#define    SLIST_REMOVE(head, elm, type, field) do {            \
if ((head)->slh_first == (elm)) {                \
}                                \
else {                                \
struct type *curelm = (head)->slh_first;        \
while(curelm->field.sle_next != (elm))            \
curelm = curelm->field.sle_next;        \
curelm->field.sle_next =                \
curelm->field.sle_next->field.sle_next;        \
}                                \
} while (/*CONSTCOND*/0)

for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)

/*
*/
#define    SLIST_NEXT(elm, field)    ((elm)->field.sle_next)

struct num_entry {
double num;
SLIST_ENTRY(num_entry) entries;
};

#define my_abs(x) ((x)>0?(x):-(x))

double my_sqrt(double c) {
double err = 1e-15;
double t = c;
if (c < 0) {
return -1;
}
while (my_abs(t- c/t) > err * t) {
t = (c/t + t) / 2.0;
}
return t;
}

int main() {
struct num_entry *np;
unsigned long long m;

/* https://acm.timus.ru/help.aspx?topic=cpp */
while (scanf("%llu ", &m) != EOF) {
#ifndef ONLINE_JUDGE
printf("m=%llu\n", m);
#endif
np = (struct num_entry *)malloc(sizeof(struct num_entry));
np->num = (double)m;