-1
lien problème: http://www.spoj.com/problems/LASTDIG2/ idée de modèle: https://brilliant.org/wiki/finding-the-last-digit-of-a-power/Je reçois WA avec mon code dans spoj-LASTDIG2 - Le dernier chiffre revisité?
#include <iostream>
using namespace std;
int t , n ;unsigned long long m;
int a2 [4] = {2,4,8,6};
int a3 [4] = {3,9,7,1}, a4 [2] = {4,6};
int a5 = 5,a6 =6;
int a7 [4] = {7,9,3,1}, a8 [4] = {8,4,2,6}, a9 [2] = {9,1},led[10] = {1,1,4,4,2,1,1,4,4,2};
int ans(int y,int i){if(y == 0 || y==1 || y==5 || y== 6){return y;}if(y== 2){return a2[i];}if(y==3){return a3[i];}if(y==4){a4[i];}if(y==7){return a7[i];}if(y==8){return a8[i];}if(y==9){return a9[i];}
}
int main()
{
int x,i;cin>>t;
while(t--)
{
cin>>n>>m;
if (n==0 || n==1 ||m==0){cout<<1<<endl;continue;}x = n%10;i = (m%led[x])-1;cout<<ans(x,i)<<endl;}
return 0;
}
La taille maximale d'un fichier est de 700 octets –
StackOverflow n'est pas destiné aux questions de programmation concurrentielle –