trafik

Untitled

May 9th, 2022
718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <cmath>
  5. #include <algorithm>
  6. #include <set>
  7. #include <iomanip>
  8. #include <string>
  9.  
  10. using namespace std;
  11.  
  12. int main() {
  13.     cin.tie(nullptr);
  14.     cout.tie(nullptr);
  15.     ios_base::sync_with_stdio(false);
  16.     int n; cin >> n;
  17.     if (n==1) {
  18.         cout << "3\n1\n5\n6";
  19.     } else {
  20.         string a1="5", a2="6";
  21.         long long of1=2, of2=3;
  22.         for (int i = 1; i<n; i++) {
  23.             for (int j = 1; j<i; j++) {
  24.                 of1+=((a1[j]-'0')*(a1[i-j]-'0'));
  25.             }
  26.             a1.push_back('0'+((of1+10)%10));
  27.             of1+=10*((of1+10)%10);
  28.             of1/=10;
  29.             /////////////////////////////////
  30.             for (int j = 1; j<i; j++) {
  31.                 of2+=((a2[j]-'0')*(a2[i-j]-'0'));
  32.             }
  33.             a2.push_back('0'+((10-((of2+10)%10))%10));
  34.             of2+=12*((10-((of2+10)%10))%10);
  35.             of2/=10;
  36.         }
  37.         vector<string> ans;
  38.         if (a1[n-1]!='0') {
  39.             reverse(a1.begin(), a1.end());
  40.             ans.push_back(a1);
  41.         }
  42.         if (a2[n-1]!='0') {
  43.             reverse(a2.begin(), a2.end());
  44.             ans.push_back(a2);
  45.         }
  46.         sort(ans.begin(), ans.end());
  47.         cout << ans.size() << '\n';
  48.         for (string s: ans) {
  49.             cout << s << '\n';
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment