Photolog

Through the Looking-Glass
2010-10-12: Through the Looking-Glass
My radio speaks is binary!
2010-10-10: My radio speaks is binary!
Gigaminx: (present for my birthday)
2010-09-16: Gigaminx: (present for my birthday)
Trini on bike
2010-09-05: Trini on bike
Valporquero
2010-08-28: Valporquero
My new bike!
2010-08-22: My new bike!
Mario and Ana's wedding
2010-08-13: Mario and Ana's wedding
Canyoning in Guara
2010-08-07: Canyoning in Guara
Trini and Mari in Marbella
2010-08-05: Trini and Mari in Marbella
Trini and Chelo in Tabarca
2010-08-03: Trini and Chelo in Tabarca
Valid XHTML 1.1
Log in
Back to list of problems

Packets

311.c

/* Packets */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>

int main(void)
{
	int num;
	int p[7];
	int sitio[7];
	int a;

	while(1) {
		scanf("%d %d %d %d %d %d", &p[1], &p[2], &p[3], &p[4], &p[5], &p[6]);
		if (p[1]==0 && p[2]==0 && p[3]==0 && p[4]==0 && p[5]==0 && p[6]==0) {
			exit(0);
		}
		num=0;
		sitio[1]=sitio[2]=sitio[3]=sitio[4]=sitio[5]=sitio[6]=0;
		num+=p[6];                  /* 6 finished */
		num+=p[5];
		sitio[1] += 11*p[5];        /* 5 finished */
		num+=p[4];
		sitio[1] += 20*p[4];
		sitio[2] += 5*p[4];         /* 4 finished */
		num+=(p[3]+3)/4;
		a = 4-(p[3]%4);
		if (a==4) a=0;
		sitio[1] += 9*a;
		switch(a) {
			case 1: sitio[2]++;
					break;
			case 2: sitio[2]+=3;
					break;
			case 3: sitio[2]+=5;
					break;
			default:
					;
		}                           /* 3 finished */

		if (p[2] <= sitio[2]) {
			sitio[1] -= 4*p[2];
		} else {
			p[2] -= sitio[2];
			sitio[1] -= 4*sitio[2];
			num += (p[2]+8)/9;
			a = 9-(p[2]%9);
			if (a==9) a=0;
			sitio[1] += 4*a;
		}                           /* 2 finished */
		if (p[1] <= sitio[1]) {
			;
		} else {
			p[1] -= sitio[1];
			num += (p[1]+35)/36;
		}
		printf("%d\n", num);
	}
	exit(0);
}