Codeforces Beta Round 99 (Div. 2) 139A - Petr and Book Solution
Problem Link : https://codeforces.com/problemset/problem/139/A
Solution in C++:
- /// La ilaha illellahu muhammadur rasulullah
- ///******Bismillahir-Rahmanir-Rahim******///
- /// Abul Hasnat Tonmoy
- /// Department of CSE,23rd batch
- /// Islamic University,Bangladesh
- ///**********ALLAH IS ALMIGHTY************///
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n ;
- cin >> n ;
- int a[9] ;
- for ( int i = 1 ; i <= 7 ; i++ ) {
- cin >> a[i] ;
- }
- int sum = 0 , i = 1 ;
- while (1) {
- sum += a[i] ;
- i++ ;
- if ( sum >= n ) {
- cout << i - 1 << endl ;
- break ;
- }
- if ( i == 8) {
- i = 1 ;
- }
- }
- return 0;
- }
No comments