January 2020

In sooth I know not why I am so sad...

Solution


#include<bits/stdc++.h>
#define MOD(ll)(1e9+7)
using namespace std;
typedef long long int ll;

int main()
{
        ios_base::sync_with_stdio(false);cin.tie(NULL);
        
        int t;
        cin>>t;
        while(t--)
        {
            string n;
            ll x;
            cin>>n>>x;
            
            int l = n.length();
            ll rem[l];
            rem[0] = (n[0]-'0')%x;
            int flag=0;
            for(int k=0;k<l-1;k++)
            {
                rem[k+1] = (rem[k]*10+ (n[k+1]-'0'))%x;
                if(rem[k+1]==0)
                {
                    
                    flag=1;
                    break;
                }
            }
            
            if(flag)
             cout<<"Aye"<<endl;
            else
                cout<<"Nay"<<endl;

        }

        return 0;
}