SHARE
TWEET

Untitled

lalalalalalalaalalla Jul 7th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <iomanip>
  5. #include <queue>
  6. #include <cmath>
  7. #include <algorithm>
  8. #include <tuple>
  9. #include <iomanip>
  10. #include <stdio.h>
  11. #include <numeric>
  12. #include <map>
  13. #include <math.h>
  14. #include <bitset>
  15.  
  16. #define int long long
  17. #define ull unsigned long long
  18. #define all(a) a.begin(), a.end()
  19. #define pii pair<int, int>
  20. #define pb push_back
  21.  
  22. using namespace std;
  23.  
  24. const double PI = 3.14159265358;
  25.  
  26. long long gcd(long long a, long long b) {
  27.     if (a==0) return b;
  28.     if (b==0) return a;
  29.     if (a>b) return gcd(a%b,b); else return gcd(b%a,a);
  30. }
  31. int prime(int p) { // 1 - простое
  32.     for (int i=2;i*i<=p;i++) {
  33.         if (p%i==0 && i<p) return 0;
  34.     }
  35.     return 1;
  36. }
  37.  
  38. double s(int x1, int y1, int x2, int y2) {
  39.     return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  40. }
  41.  
  42. int t(string s) {
  43.     return (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
  44. }
  45.  
  46. signed main()
  47. {
  48.     ios_base::sync_with_stdio(0);
  49.     cin.tie(0);
  50.     cout.tie(0);
  51.     string s;
  52.     cin >> s;
  53.     int cnt = 0;
  54.     string k = "", c;
  55.     for (int i = 0; i < 8; i++) {
  56.         sort(all(s));
  57.         k = s;
  58.         reverse(all(s));
  59.         cout << s << " ";
  60.         s = to_string(t(s) - t(k));
  61.         while (s.size() < 4) {
  62.             s = "0" + s;
  63.         }
  64.         cout << k << " " << s << "\n";
  65.         sort(all(s));
  66.         if (s == k) {
  67.             cout << 6174 << "\n" << i;
  68.             break;
  69.         }
  70.     }
  71. }
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