VvyLw's Library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub

:heavy_check_mark: test/add128_2.test.cpp

Depends on

Code

#define PROBLEM "https://judge.yosupo.jp/problem/many_aplusb_128bit"
#include "C++/core/io/input.hpp"
#include "C++/core/io/output.hpp"
using namespace IO;
#include <ranges>
namespace man {
typedef __int128_t i128;
inline i128 solve() noexcept {
    i128 a, b;
    IO::input(a, b);
    return a + b;
}
}
int main() {
    std::cin.tie(nullptr) -> sync_with_stdio(false);
    int t;
    std::cin >> t;
    for([[maybe_unused]] const auto _: std::views::iota(0, t)) {
        IO::println(man::solve());
    }
}
#line 1 "test/add128_2.test.cpp"
#define PROBLEM "https://judge.yosupo.jp/problem/many_aplusb_128bit"
#line 2 "C++/core/io/input.hpp"

#include <iostream>
#include <cassert>
#include <array>
#include <vector>
#include <deque>
#ifndef TEMPLATE
namespace man {
constexpr inline bool isdigit(const char c) noexcept { return std::isdigit(c); }
inline bool isdigit(const std::string &s) noexcept {
    bool ok = true, neg = s.front() == '-';
    for(const auto &el: s) {
        if(neg) {
            neg = false;
            continue;
        }
        ok &= isdigit(el);
    }
    return ok;
}
}
#endif
namespace IO {
inline std::istream& operator>>(std::istream &is, __int128_t &val) noexcept {
    std::string s;
    std::cin >> s;
    assert(man::isdigit(s));
    bool neg = s.front() == '-';
    val = 0;
    for(const auto &el: s) {
        if(neg) {
            neg = false;
            continue;
        }
        val = 10 * val + el - '0';
    }
    if(s.front()=='-') {
        val = -val;
    }
    return is;
}
template <class T, class U> inline std::istream& operator>>(std::istream &is, std::pair<T, U> &p) noexcept { is >> p.first >> p.second; return is; }
template <std::ranges::random_access_range T> requires (!std::same_as<std::remove_cvref_t<T>, std::string> && !std::same_as<std::remove_cvref_t<T>, std::string_view> && !std::is_array_v<std::remove_cvref_t<T>>) inline std::istream& operator>>(std::istream &is, T &v) noexcept { for(auto &el: v){ is >> el; } return is; }
template <class Head, class... Tail> inline bool input(Head &head, Tail &...tail) noexcept {
    if(!(std::cin >> head)) {
        return false;
    }
    if constexpr(sizeof...(Tail) > 0) {
        input(tail...);
    }
    return true;
}
} // IO

/**
 * @brief 入力
 */
#line 2 "C++/core/io/output.hpp"

#line 5 "C++/core/io/output.hpp"
#include <map>
namespace IO {
inline std::ostream &operator<<(std::ostream &dest, const __int128_t &value) noexcept {
    std::ostream::sentry s(dest);
    constexpr char dig[] = "0123456789";
    if(s) {
        __uint128_t tmp = value < 0 ? -value : value;
        char buffer[128];
        char *d = std::end(buffer);
        do {
            --d;
            *d = dig[tmp % 10];
            tmp /= 10;
        } while(tmp != 0);
        if(value < 0) {
            --d;
            *d = '-';
        }
        const int len = std::end(buffer) - d;
        if(dest.rdbuf() -> sputn(d, len) != len) {
            dest.setstate(std::ios_base::badbit);
        }
    }
    return dest;
}
template <class T, class U> inline std::ostream& operator<<(std::ostream &os, const std::pair<T, U> &p) noexcept { os << p.first << ' ' << p.second; return os; }
template <class K, class V> inline std::ostream& operator<<(std::ostream &os, const std::map<K, V> &m) noexcept {
    if(!m.empty()) {
        os << m.begin()->first << ' ' << m.begin()->second;
        for(auto i = m.begin(); ++i != m.end();) {
            os << '\n' << i->first << ' ' << i->second;
        }
    }
    return os;
}
template <std::ranges::range T> requires (!std::same_as<std::remove_cvref_t<T>, std::string> && !std::same_as<std::remove_cvref_t<T>, std::string_view> && !std::is_array_v<std::remove_cvref_t<T>>) inline std::ostream& operator<<(std::ostream &os, const T &v) noexcept {
    if(!v.empty()) {
        os << *v.cbegin();
        for(auto i = v.cbegin(); ++i != v.cend();) {
            os << ' ' << *i;
        }
    }
    return os;
}
enum Flash { non_flush, flush };
template <Flash f = non_flush, class Head, class... Tail> inline void print(const Head& head, const Tail& ...tail) noexcept {
    std::cout << head;
    if constexpr(sizeof...(Tail) > 0) {
        std::cout << ' ';
        print<f>(tail...);
    } else {
        if constexpr(f == flush) {
            std::cout.flush();
        }
    }
}
inline void println() noexcept { std::cout << '\n'; }
template <Flash f = non_flush, class Head, class... Tail> inline void println(const Head& head, const Tail& ...tail) noexcept { print<f>(head, tail...); std::cout << '\n'; }
} // IO

using enum IO::Flash;

#if local
//https://gist.github.com/naskya/1e5e5cd269cfe16a76988378a60e2ca3
#include <C++/core/io/debug_print.hpp>
#else
#define dump(...) static_cast<void>(0)
#endif

/**
 * @brief 出力
 */
#line 4 "test/add128_2.test.cpp"
using namespace IO;
#include <ranges>
namespace man {
typedef __int128_t i128;
inline i128 solve() noexcept {
    i128 a, b;
    IO::input(a, b);
    return a + b;
}
}
int main() {
    std::cin.tie(nullptr) -> sync_with_stdio(false);
    int t;
    std::cin >> t;
    for([[maybe_unused]] const auto _: std::views::iota(0, t)) {
        IO::println(man::solve());
    }
}
Back to top page