1 / 3
Sep 2020

i dont know whats wrong with the code. its working fine and giving desired output in my pc. But SPOJ is saying its wrong. pls help me out.

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int test;
    cin>>test;
    for(int i=0;i<test;i++)
    {
        int a,b,c;
        cin>>a>>b;
        vector<int> v;
        c=a%10;
        v.push_back(c);
        for(int j=2;j<=10;j++)
        {   c=(c*(a%10))%10;
            if(find(v.begin(),v.end(),c)==v.end())
            v.push_back(c);
            else
            break;
        }
        if(v.size()==1)
        cout<<v[0]<<endl;
        else
        cout<<v[(b%v.size())-1]<<endl;
    }




    return 0;
}
  • created

    Sep '20
  • last reply

    Sep '20
  • 2

    replies

  • 649

    views

  • 2

    users

Try these. My AC solution doesn’t give 0 for any of them, but yours does.

4
13 122232
4 762539252
3 560086844
18 840507520