Asa's CP Library

a01sa01to's competitive programming library.

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

View the Project on GitHub a01sa01to/cp-library

:heavy_check_mark: tests/samples/many-aplusb-128bit.test.cpp

Code

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

#define PROBLEM "https://judge.yosupo.jp/problem/many_aplusb_128bit"

istream& operator>>(istream& is, __int128_t& x) {
  string s;
  is >> s;
  x = 0;
  for (size_t i = (s[0] == '-'); i < s.size(); ++i) x = x * 10 + s[i] - '0';
  if (s[0] == '-') x = -x;
  return is;
}

ostream& operator<<(ostream& os, __int128_t x) {
  if (x < 0) os << '-', x = -x;
  if (x == 0) return os << '0';
  string s;
  while (x > 0) {
    s.push_back('0' + x % 10);
    x /= 10;
  }
  reverse(s.begin(), s.end());
  return os << s;
}

istream& operator>>(istream& is, __uint128_t& x) {
  string s;
  is >> s;
  x = 0;
  for (size_t i = 0; i < s.size(); ++i) x = x * 10 + s[i] - '0';
  return is;
}

ostream& operator<<(ostream& os, __uint128_t x) {
  if (x == 0) return os << '0';
  string s;
  while (x > 0) {
    s.push_back('0' + x % 10);
    x /= 10;
  }
  reverse(s.begin(), s.end());
  return os << s;
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    __int128_t a, b;
    cin >> a >> b;
    cout << a + b << '\n';
  }
  return 0;
}
#line 1 "tests/samples/many-aplusb-128bit.test.cpp"
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

#define PROBLEM "https://judge.yosupo.jp/problem/many_aplusb_128bit"

istream& operator>>(istream& is, __int128_t& x) {
  string s;
  is >> s;
  x = 0;
  for (size_t i = (s[0] == '-'); i < s.size(); ++i) x = x * 10 + s[i] - '0';
  if (s[0] == '-') x = -x;
  return is;
}

ostream& operator<<(ostream& os, __int128_t x) {
  if (x < 0) os << '-', x = -x;
  if (x == 0) return os << '0';
  string s;
  while (x > 0) {
    s.push_back('0' + x % 10);
    x /= 10;
  }
  reverse(s.begin(), s.end());
  return os << s;
}

istream& operator>>(istream& is, __uint128_t& x) {
  string s;
  is >> s;
  x = 0;
  for (size_t i = 0; i < s.size(); ++i) x = x * 10 + s[i] - '0';
  return is;
}

ostream& operator<<(ostream& os, __uint128_t x) {
  if (x == 0) return os << '0';
  string s;
  while (x > 0) {
    s.push_back('0' + x % 10);
    x /= 10;
  }
  reverse(s.begin(), s.end());
  return os << s;
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    __int128_t a, b;
    cin >> a >> b;
    cout << a + b << '\n';
  }
  return 0;
}
Back to top page