fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. long long stoi_a(string s) {
  4. long long n = 0;
  5. for (int i = 0; i < s.size(); ++i) {
  6. n = n * 10 + (s[i] - 48);
  7. }
  8. return n;
  9. }
  10. int main()
  11. {
  12. string n;
  13. cin >> n;
  14. long long lt = n.size();
  15. long long sum = 0;
  16. for (auto i : n)
  17. sum += (long long)(pow(i - '0', lt));
  18. long long new_num = stoi_a(n);
  19. if (sum == new_num) cout << "true" << '\n';
  20. else cout << "false" << '\n';
  21. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
true