Cod sursa(job #238331)

Utilizator drag0s93Mandu Dragos drag0s93 Data 1 ianuarie 2009 21:28:16
Problema Energii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include<stdio.h>
int g,w,eg,cg;
void calcul()
{
	int e=0,cost=0,ce=0,ccost=0;
	for(int i=0;i<=g;++i)
	{
		scanf("%d%d",&eg,&cg);
		while(e!=w)
		{
			e=eg+e;
			cost=cost+cg;
		}
		if(ccost==0)
			ccost=cost;
		if(cost<ccost)
			ccost=cost;
		e=0;
		cost=0;
	}
	printf("%d",ccost);
}
int main()
{
	freopen("energii.in","r",stdin);
	freopen("energii.out","w",stdout);
	scanf("%d%d",&g,&w);
	calcul();
	return 0;
}