Cod sursa(job #680029)

Utilizator Roninsabau sabin nicolae cristian Ronin Data 14 februarie 2012 00:08:15
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include<stdio.h>
int main()
{
	int i[12]={0};
	unsigned long long n=0,a=0,p;
	freopen("fact.in","r",stdin);
	freopen("fact.out","w",stdout);
	scanf("%d",&p);
	while(a<p)
	{n++;a++;i[1]++; if(i[1]==5)
	{a++;i[2]++;i[1]=0;  if(i[2]==5)
	{a++;i[3]++;i[2]=0;  if(i[3]==5)
	{a++;i[4]++;i[3]=0;  if(i[4]==5)
	{a++;i[5]++;i[4]=0;  if(i[5]==5)
	{a++;i[6]++;i[5]=0;  if(i[6]==5)
	{a++;i[7]++;i[6]=0;  if(i[7]==5)
	{a++;i[7]=0;i[8]++;  if(i[8]==5)
	{a++;i[8]=0;i[9]++;  if(i[9]==5)
	{a++;i[9]=0;i[10]++  if(i[10]==5)
	{a++;i[10]=0;}}}}}}}}}}}
	if(a>p) printf("%d",-1);
	else printf("%d",5*n);
	return 0;
}