Advertisement
IstiakAhmedSifat

Untitled

Feb 26th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.42 KB | None | 0 0
  1.     #include<bits/stdc++.h>
  2.     using namespace std;
  3.     #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  4.     vector<long long>vprime;
  5.     void SieveOfEratosthenes(int n)
  6.     {
  7.         bool prime[n+1];
  8.         memset(prime, true, sizeof(prime));
  9.         for (int p=2; p*p<=n; p
  10.         ++)
  11.         {
  12.             if (prime[p] == true)
  13.             {
  14.                 for (int i=p*p; i<=n; i += p)
  15.                     prime[i] = false;
  16.             }
  17.         }
  18.         for (int p=2; p<=n; p++)
  19.            if (prime[p])
  20.               vprime.push_back(p);
  21.     }
  22.     int countFreq(string &pat, string &txt)
  23.     {
  24.         int M = pat.length();
  25.         int N = txt.length();
  26.         int res = 0;
  27.  
  28.         /* A loop to slide pat[] one by one */
  29.         for (int i = 0; i <= N - M; i++)
  30.         {
  31.             /* For current index i, check for
  32.                pattern match */
  33.             int j;
  34.             for (j = 0; j < M; j++)
  35.                 if (txt[i+j] != pat[j])
  36.                     break;
  37.  
  38.             // if pat[0...M-1] = txt[i, i+1, ...i+M-1]
  39.             if (j == M)
  40.             {
  41.                res++;
  42.                j = 0;
  43.             }
  44.         }
  45.         return res;
  46.     }
  47.     int main()
  48.     {
  49.         IOS;
  50.         long long a,b,c,d,e,g,h,k,l,m,n,t,f,f1=0,flag2=0,flag=0,flag1=0,co=0,co1=0,co2=0,sum=0,sum1=0,ma=0,ma1=0,ma2=0,mi=100000000000,mi1=100000000000,mi2=100,mi3=1000;
  51.         long long co3=0,co4=0,co5=0,co6=0,co7=0,co8=0,mul=1,sum2=0;
  52.         long long arr[100001],arr1[100001]={0};
  53.         long long a1,a2,b1,b2,c1,c2,a3,a4,b3,b4,b5,b6,m1,m2,k1,l1,m3,m4,d1,d2;
  54.         double pi=2 * acos (0.0);
  55.  
  56.         char ch;
  57.         //set<long long>::iterator it;
  58.         //vector<long long>v;
  59.         string str,str1,str2,str3,str4,str5;
  60.  
  61.         //vector<string>vs;
  62.         //vector<string>vs1;
  63.         //vector<pair<long long,pair<long long, long long> > >v;
  64.         //set<string>s;
  65.         set<long long>s1;
  66.         set<long long>s2;
  67.         set<long long>s3;
  68.         //map< char,long long > mp1;
  69.         stack<long long>st;
  70.         //list<long long>li;
  71.         int x[]={1,-1,1,-1,2,2,-2,-2};
  72.         int y[]={2,2,-2,-2,1,-1,1,-1};
  73.         //int x[]={1,0,0,-1};
  74.         //int y[]={0,1,-1,0};
  75.         //map< long long,long long > mp;
  76.         //map< long long,long long>::iterator it;
  77.         //vector<pair<long long,long long> >v3;
  78.         cin>>t;
  79.         while(t--)
  80.         {
  81.  
  82.  
  83.         cin>>a>>b;
  84.         if(b==0)
  85.         {
  86.             cout<<a<<endl;
  87.             continue;
  88.         }
  89.         c=1;
  90.         for(int i=1; i<=b; i++)
  91.         {
  92.             c=c*10;
  93.         }
  94.         e=a%10;
  95.         if(e%2==0 || e==5)
  96.         {
  97.             for(int i=1; i<=c; i++)
  98.             {
  99.                 co=0;
  100.                 d=a*i;
  101.                 f=d;
  102.                 flag=0;
  103.                 while(d>0)
  104.                 {
  105.                     g=d%10;
  106.                     if(g==0)
  107.                     {
  108.                         co++;
  109.                         if(co==b)
  110.                         {
  111.                             cout<<f<<endl;
  112.                             flag=1;
  113.                             break;
  114.                         }
  115.                     }
  116.                     else break;
  117.                     d=d/10;
  118.                 }
  119.                 if(flag==1)
  120.                     break;
  121.             }
  122.         }
  123.         else cout<<a*c<<endl;
  124.         }
  125.         return 0;
  126.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement