Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- #include <vector>
- #include <string>
- #include <math.h>
- #define ll long long
- using namespace std;
- //freopen("a.in", "r", stdin);
- //freopen("a.out", "w", stdout);
- int n;
- ll v_n_sum(ll t){
- ll sum = 0;
- while(t > 0){
- sum += t % n;
- t /= n;
- }
- return sum;
- }
- int main()
- {
- ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- ll x = 1, y;
- cin >> n;
- bool f = false;
- ll now = 1;
- ll sum_n, sum_del;
- bool count = false;
- bool g;
- while(true){
- g = false;
- sum_del = 0;
- sum_n = v_n_sum(x);
- y = x;
- for (ll i = 2; i*i <= y; i++) {
- while (y % i == 0) {
- g = true;
- sum_del += v_n_sum(i);
- y /= i;
- }
- }
- if(g){
- if (y > 1)
- sum_del += v_n_sum(y);
- if(sum_n == sum_del){
- if(f){
- if(!count){
- count = true;
- f = false;
- } else{
- cout << now;
- return 0;
- }
- }else{
- now = x;
- f = true;
- }
- } else
- f = false;
- } else
- f = false;
- x++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement