Codeforces 1604C - Di-visible Confusion 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,n,i,c,j,ans;
    6. cin>>t;
    7. while(t--)
    8. {
    9. c=0,ans=0;
    10. cin>>n;
    11. int a[n+9];
    12. for(i=1; i<=n; i++)cin>>a[i];
    13. for(i=1; i<=n; i++)
    14. {
    15. c=0;
    16. for(j=2; j<=i+1;j++)
    17. {
    18. if(a[i]%j!=0)
    19. {
    20. c=1;
    21. break;
    22. }
    23. }
    24. if(c==0)
    25. {
    26. ans=1;
    27. break;
    28. }
    29. }
    30. if(ans==1)
    31. cout<<"NO"<<endl;
    32. else
    33. cout<<"YES"<<endl;
    34. }
    35. }

    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 &g...

    Powered by Blogger.