Cod sursa(job #6808)

Utilizator dragos_dDiaconescu Dragos dragos_d Data 20 ianuarie 2007 23:26:54
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include "fstream.h"
#include "math.h">

ifstream f("cifra.in");
ofstream g("cifra.out");
int main()
{int t,i,j,cifra,x,exp,y;
 f>>t;
 for(i=1;i<=t;i++)
 {
     f>>x;
     cifra=0;
     for(j=1;j<=x;j++)
     {
	exp=j;
	if(j>4)
	{
	exp=j%4;
	if(exp==0)
	  exp=4;
	}
     y=pow(j,exp);
     cifra+=y;
     cifra=cifra%10;
     }
 g<<cifra;
 g<<"\n";
 }

return 0;
}