Codeforces Round 876 (Div. 2) 1839A. The Good Array Solution


  

Problem Link :  https://codeforces.com/contest/1839/problem/A

Solution in C++:

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int32_t main() {
  4. ios_base::sync_with_stdio(0);
  5. cin.tie(0);
  6. int t;
  7. cin >> t;
  8. while (t--) {
  9. int n , k ;
  10. cin >> n >> k ;
  11. int r = ( n + k - 1) / k ;
  12. if ((( n % k == 0) and k > 1) or n % k > 1 ) r ++ ;
  13. cout << r <<'\n' ;
  14. }
  15. return 0 ;
  16. }

No comments

Most View Post

Recent post

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.