* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Ghajini and his revenge
Survey
Document related concepts
Transcript
Ghajiniandhis revenge Ghajiniwantstotakerevengeofhisgirlfriendandislookingforcluesbyfindingthesequencenumbers. Sincehesufferesfromshorttermmemoryloss,heisveryfondofnumbersandsequencesandcan rememberonlythelastdigitofS. Heisconfusedbecauseofhisdisorderandleavesthisproblemtotheworthyprogrammers.HelpGhijiniin findingthesolution. InputFormat ThefirstlinecontainsT,thenumberoftestcases.Tlinesfollow,eachlinecontaininganinteger,N. OutputFormat Foreachtestcase,printthelastdigitofSinoneline. Constraints 1≤T≤1000 1≤N≤1015 SampleInput 3 1 2 3 SampleOutput 0 6 0 Explanation Forn=1,onlyi=0isvalid.SoSis2 2 0+0 +2 2 Forn=2,onlyi=0and1arevalid.SoSis S1(fori=0)is2 2 0+0 +2 2 0+2 +2 2 0+4 =42 S2(fori=1)is2 2 1+0 +2 2 1+2 +2 2 1+4 =84 SolastdigitofSis6. 0+2 =10.HencelastdigitofSis0.