Codeforces 1526B. I Hate 1111 Solution

 ///La ilaha illellahu muhammadur rasulullah

///******Bismillahir-Rahmanir-Rahim******///

///Abul Hasnat  Tonmoy

///Department of CSE,23rd batch

    ///Islamic University,Bangladesh

    1. #include <bits/stdc++.h>
    2. using namespace std;
    3. int main()
    4. {
    5. int t,x,i,ans,v;
    6. cin>>t;
    7. while(t--)
    8. {
    9. ans=0;
    10. cin>>x;
    11. for(i=0; i*111<=x; i++)
    12. {
    13. v=x-(111*i);
    14. if(v%11==0)
    15. {
    16. ans=1;
    17. break;
    18. }
    19.  
    20. }
    21. if(ans==1)
    22. cout<<"YES"<<endl;
    23. else
    24. cout<<"NO"<<endl;
    25. }
    26. }
    27.  

    No comments

    Most View Post

    Recent post

    Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

      Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

    Powered by Blogger.