139A - Petr and Book

  1. 139A - Petr and Book
  2. #include<iostream>
  3. using namespace std;
  4. int main()
  5. {
  6. int n=0,z=0,arr[7],sum=0,ans(1), j;
  7. cin>>n;
  8. for( j=0;j<7;j++)
  9. cin>>arr[j];
  10. int x=0;
  11. while(1)
  12. {
  13. for(int i=0;i<7;i++)
  14. { n=n-arr[i];
  15. x++; //cout<<n<<" ";
  16. if(n<=0) break;
  17.  
  18.  
  19.  
  20.  
  21. }
  22.  
  23. if(n<=0){ break;}
  24.  
  25. }
  26. if(x%7==0)
  27. cout<< 7;
  28. else cout<<x%7;
  29.  
  30. return 0;
  31.  
  32. }

Comments

Popular posts from this blog

Codeforce Problem 1703A. YES or YES?

Aptitude test assistant programmer 2018

1041A. Heist solution