SHARE
TWEET

Untitled

a guest Oct 10th, 2019 115 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int size_str(string s){
  6.     int sum = 0;
  7.     for (int i = 0; i < s.length(); ++i){
  8.         sum += s[i] - '0';
  9.     }
  10.     return sum;
  11. }
  12.  
  13. int main() {
  14.     string s;
  15.     cin >> s;
  16.  
  17.     int sum = size_str(s);
  18.  
  19.     for(int i = 0; i < s.length(); ++i){
  20.         string s1 = s;
  21.         while (s1[i] < '9') {
  22.             s1[i]++;
  23.             if (s1[i] <= '6') {
  24.                 continue;
  25.             }
  26.             int sum1 = size_str(s1);
  27.             if (sum1 % 3 == 0) {
  28.                 cout << s1;
  29.                 return 0;
  30.             }
  31.         }
  32.     }
  33.     cout << sum;
  34.     return 0;
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top