artemgf

Не спрашивай даму о возрасте

Oct 29th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <string>
  5. #include <algorithm>
  6. #include <vector>
  7. #include <map>
  8. #include <queue>
  9. #include <set>
  10.  
  11. using namespace std;
  12.  
  13. double convert10(vector<long long> k, int step)
  14. {
  15.     double answ=0;
  16.     double Pow = k.size() - 1;
  17.     for (auto i = k.begin(); i != k.end(); i++)
  18.     {
  19.         answ += (*i);
  20.         Pow--;
  21.     }
  22.     return answ;
  23. }
  24. int main()
  25. {
  26.     long long max = -1;
  27.     char ediniz;
  28.     vector<long long> k;
  29.  
  30.     while (cin >> ediniz)
  31.     {
  32.         long long dic;
  33.         if (ediniz >= '0'&&ediniz <= '9')
  34.         {
  35.             dic = ediniz - '0';
  36.         }
  37.         else
  38.             dic = ediniz - 'A' + 10;
  39.         if (max < dic)
  40.             max = dic;
  41.         k.push_back(dic);
  42.     }
  43.     bool was = false;
  44.     for (int i = max+1; i <= 37; i++)
  45.     {
  46.         long long edin10 = convert10(k, i);
  47.         if (edin10 <= 1)
  48.         {
  49.             cout << "2";
  50.             was = true;
  51.             break;
  52.         }
  53.         if (edin10%(i-1) == 0)
  54.         {
  55.             cout << i << endl;
  56.             was = true;
  57.             break;
  58.         }
  59.     }
  60.     if (!was)
  61.     {
  62.         cout << "No solution.";
  63.     }
  64.     system("pause");
  65.     return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment