Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <cstdint>
- #include <algorithm>
- #include <string>
- std::string to_string(__uint128_t n) {
- std::string res;
- do {
- res += '0' + n % 10;
- n /= 10;
- } while (n != 0);
- std::reverse(res.begin( ), res.end( ));
- return res;
- }
- __uint128_t exp(__uint128_t a, __uint128_t n) {
- __uint128_t res = 1;
- for (; n; n >>= 1) {
- if (n & 1) {
- res *= a;
- }
- a *= a;
- }
- return res;
- }
- int main( ) {
- uint64_t a, b;
- std::cin >> a >> b;
- __uint128_t n = exp(a, b);
- n = floor(log10(n)) + 1;
- std::cout << to_string(n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement