Cod sursa(job #257723)

Utilizator mathboyDragos-Alin Rotaru mathboy Data 13 februarie 2009 21:14:07
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.19 kb
#include <fstream.h>
ifstream f("cifra.in");
ofstream g("cifra.out");
int main()
{
 long unsigned s,i,j,t,n,nr=0;
 f>>t;
 for(i=1;i<=t;i++)
	{f>>n;nr=0;
	if(n==0) g<<0;
{ for(j=1;j<=n;j++)
  if(j%10==1) nr=nr+1;break;
 else if(j%10==2)
	{ if(j%4==0) nr=nr+6;break;
	 else if(j%4==1) nr=nr+2;break;
	 else if(j%4==2) nr=nr+4;break;
	 else if(j%4==3) nr=nr+8;break;
	  }
 else if(j%10==3)
	{ if(j%4==0) nr=nr+1;break;
	 else if(j%4==1) nr=nr+3;break;
	 else if(j%4==2) nr=nr+9;break;
	 else if(j%4==3) nr=nr+7;break;
	 }
  else if(j%10==4)
	{ if(j%2==0) nr=nr+6;break;
	 else if(j%2==1) nr=nr+4;break;
	  }
  else if(j%10==5)
	{ if(j%2==0) nr=nr+0;break;
	else if(j%2==1) nr=nr+5;break;
	 }
  else if(j%10==6) nr=nr+6;break;
  else if(j%10==7)
	{ if(j%4==0) nr=nr+1;break;
	 else if(j%4==1) nr=nr+7;break;
	 else if(j%4==2) nr=nr+9;break;
	 else if(j%4==3) nr=nr+3;break;
	 }
   else if(j%10==8)
	{ if(j%4==0) nr=nr+6;break;
       else	 if(j%4==1) nr=nr+8;break;
       else	 if(j%4==2) nr=nr+2;break;
       else	 if(j%4==3) nr=nr+2;break;
	 }
else if(j%10==9)
	{ if(j%2==0) nr=nr+1;break;
	else  if(j%2==1) nr=nr+9;break;
	 }
	}g<<nr%10<<"\n";}

	return 0;
	}