Cod sursa(job #2177758)

Utilizator Baba_DorinBaba Dorin Baba_Dorin Data 18 martie 2018 19:58:14
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.78 kb
#include <iostream>
#include <math.h> //ridicare la putere
#include <vector>
#include <string>
#include <sstream>
#include <fstream>
 template <typename T>
    std::string to_string(T value)
    {
      std::ostringstream os ;
      os << value ;

	  return os.str() ;
    }

using namespace std;
int main(int argc, char** argv) {
	string sum;
	ifstream fin("cifra.in");
	ofstream fout("cifra.out");
	int t; fin>>t;
	vector <long int> n(t);
	long int suma=0;
	for (int i=0; i<t; i++){
		fin>>n[i];
	}
	//long int n;
	for (int j=0; j<t; j++){
	suma=0;
	for (int i=1; i<=n[j]; i++){
		suma+=pow(i,i);
	}
		sum = to_string(suma);
		//string sum = to_string(suma);
		fout<<sum[sum.length()-1]<<endl;
		suma=0;
		
	}
	fin.close();
	fout.close();

	return 0;
}