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 925 (Div. 3) 1931D. Divisible Pairs Solution

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

    Powered by Blogger.