Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <map>
- #include <cmath>
- #include <algorithm>
- #include <set>
- #include <iomanip>
- #include <string>
- using namespace std;
- int main() {
- cin.tie(nullptr);
- cout.tie(nullptr);
- ios_base::sync_with_stdio(false);
- int n; cin >> n;
- if (n==1) {
- cout << "3\n1\n5\n6";
- } else {
- string a1="5", a2="6";
- long long of1=2, of2=3;
- for (int i = 1; i<n; i++) {
- for (int j = 1; j<i; j++) {
- of1+=((a1[j]-'0')*(a1[i-j]-'0'));
- }
- a1.push_back('0'+((of1+10)%10));
- of1+=10*((of1+10)%10);
- of1/=10;
- /////////////////////////////////
- for (int j = 1; j<i; j++) {
- of2+=((a2[j]-'0')*(a2[i-j]-'0'));
- }
- a2.push_back('0'+((10-((of2+10)%10))%10));
- of2+=12*((10-((of2+10)%10))%10);
- of2/=10;
- }
- vector<string> ans;
- if (a1[n-1]!='0') {
- reverse(a1.begin(), a1.end());
- ans.push_back(a1);
- }
- if (a2[n-1]!='0') {
- reverse(a2.begin(), a2.end());
- ans.push_back(a2);
- }
- sort(ans.begin(), ans.end());
- cout << ans.size() << '\n';
- for (string s: ans) {
- cout << s << '\n';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment