Advertisement
Mirbek

(A) Div. 7 (Codeforces)

Feb 4th, 2022
799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     int T;
  7.     cin >> T;
  8.     while (T--) {
  9.         int n;
  10.         cin >> n;
  11.         if (n % 7 == 0) {
  12.             cout << n << endl;
  13.             continue;
  14.         }
  15.         int r = n % 7;
  16.         int d = n % 10;
  17.         if (d - r >= 0) {
  18.             cout << n - r << endl;
  19.         } else {
  20.             cout << n + (7 - r) << endl;
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement