76 lines
1.7 KiB
C
76 lines
1.7 KiB
C
#include "_.h"
|
|
|
|
typedef struct structure {
|
|
int nbr;
|
|
struct structure *next;
|
|
} struc;
|
|
|
|
long long lenght_struc(struc *head) {
|
|
long long count = 0;
|
|
while (head->next != NULL) {
|
|
head = head->next;
|
|
count++;
|
|
}
|
|
return count;
|
|
}
|
|
|
|
void print_struc(struc *head) {
|
|
while (head->next != NULL) {
|
|
head = head->next;
|
|
printf("%d ", head->nbr);
|
|
}
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
if (argc != 2)
|
|
return 1;
|
|
|
|
char *input = argv[1];
|
|
char **inputs = str_split(strdup(input), ' ');
|
|
struc *head = calloc(1, sizeof(struc));
|
|
struc *cur = head;
|
|
|
|
for (int i = 0; inputs[i] != NULL; i++) {
|
|
cur->nbr = atol(inputs[i]);
|
|
cur->next = calloc(1, sizeof(struc));
|
|
cur = cur->next;
|
|
}
|
|
|
|
long long count = lenght_struc(head);
|
|
for (int i = 0; i < 75; i++) {
|
|
cur = head;
|
|
for (int j = 0; cur->next != NULL; j++) {
|
|
if (cur->nbr == 0) {
|
|
cur->nbr = 1;
|
|
cur = cur->next;
|
|
}
|
|
else if (((int)floor(log10(ABS(cur->nbr))) + 1) % 2 == 0) {
|
|
double len = floor(log10(ABS(cur->nbr))) + 1;
|
|
int left = cur->nbr / (pow(10, len / 2));
|
|
int right = cur->nbr % (int)(pow(10, len / 2));
|
|
|
|
struc *new = calloc(1, sizeof(struc));
|
|
new->nbr = right;
|
|
new->next = cur->next;
|
|
|
|
cur->nbr = left;
|
|
cur->next = new;
|
|
cur = new->next;
|
|
|
|
count++;
|
|
}
|
|
else {
|
|
cur->nbr *= 2024;
|
|
cur = cur->next;
|
|
}
|
|
}
|
|
}
|
|
|
|
//print_struc(head);
|
|
printf("count: %lld\n", count);
|
|
|
|
|
|
return 0;
|
|
}
|