Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <iomanip>
- #include <queue>
- #include <cmath>
- #include <algorithm>
- #include <tuple>
- #include <iomanip>
- #include <stdio.h>
- #include <numeric>
- #include <map>
- #include <math.h>
- #include <bitset>
- #define int long long
- #define ull unsigned long long
- #define all(a) a.begin(), a.end()
- #define pii pair<int, int>
- #define pb push_back
- using namespace std;
- const double PI = 3.14159265358;
- long long gcd(long long a, long long b) {
- if (a==0) return b;
- if (b==0) return a;
- if (a>b) return gcd(a%b,b); else return gcd(b%a,a);
- }
- int prime(int p) { // 1 - простое
- for (int i=2;i*i<=p;i++) {
- if (p%i==0 && i<p) return 0;
- }
- return 1;
- }
- double s(int x1, int y1, int x2, int y2) {
- return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
- }
- int t(string s) {
- return (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
- }
- signed main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- string s;
- cin >> s;
- int cnt = 0;
- string k = "", c;
- for (int i = 0; i < 8; i++) {
- sort(all(s));
- k = s;
- reverse(all(s));
- cout << s << " ";
- s = to_string(t(s) - t(k));
- while (s.size() < 4) {
- s = "0" + s;
- }
- cout << k << " " << s << "\n";
- sort(all(s));
- if (s == k) {
- cout << 6174 << "\n" << i;
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement