34 lines
638 B
C
34 lines
638 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main()
|
|
{
|
|
char *line = NULL;
|
|
size_t len;
|
|
int ops = 1;
|
|
int x = 1;
|
|
|
|
int signal = 0;
|
|
|
|
while (getline(&line, &len, stdin) != -1)
|
|
{
|
|
if ((ops+20) % 40 == 0) {
|
|
printf("%d %d\n", ops, x);
|
|
signal += ops * x;
|
|
}
|
|
if (line[0] == 'a') {
|
|
ops++;
|
|
if ((ops+20) % 40 == 0) {
|
|
printf("%d %d\n", ops, x);
|
|
signal += ops * x;
|
|
}
|
|
int a = atoi(line+5);
|
|
x += a;
|
|
printf("%d\n", a);
|
|
}
|
|
ops++;
|
|
}
|
|
|
|
printf("%d\n", signal);
|
|
}
|