結果

問題 No.3062 A + B
ユーザー risujirohrisujiroh
提出日時 2020-04-01 21:52:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,873 bytes
コンパイル時間 1,621 ms
コンパイル使用メモリ 166,508 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-09 17:58:39
合計ジャッジ時間 2,292 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,388 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:38:19: 警告: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’
   38 | __int128_t digits(auto& i) {
      |                   ^~~~
main.cpp:43:17: 警告: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’
   43 | __int128_t expr(auto& i);
      |                 ^~~~
main.cpp:44:16: 警告: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’
   44 | __int128_t num(auto& i) {
      |                ^~~~
main.cpp:55:17: 警告: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’
   55 | __int128_t term(auto& i) {
      |                 ^~~~
main.cpp:63:17: 警告: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’
   63 | __int128_t expr(auto& i) {
      |                 ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

char readchar() {
  static char buf[1 << 15], *ptr = buf, *end = buf;
  if (ptr == end) ptr = buf, end = buf + fread(buf, 1, 1 << 15, stdin);
  return *ptr++;
}
void writechar(char c = 0) {
  static char buf[1 << 15], *ptr = buf;
  if (ptr == end(buf) or c == 0) fwrite(buf, 1, ptr - buf, stdout), ptr = buf;
  *ptr++ = c;
}
template <class Z = int> Z getint() {
  char c = readchar();
  bool neg = c == '-';
  Z res = neg ? 0 : c - '0';
  while (isdigit(c = readchar())) res = res * 10 + (c - '0');
  return neg ? -res : res;
}
template <class Z> void putint(Z a, char delim = '\n') {
  if (a < 0) writechar('-'), a = -a;
  int d[40], i = 0;
  do d[i++] = a % 10; while (a /= 10);
  while (i--) writechar('0' + d[i]);
  writechar(delim);
}
string getstring(char delim = '\n') {
  string res;
  for (char c; (c = readchar()) != delim; ) res += c;
  return res;
}
void putstring(string s, char delim = '\n') {
  for (char c : s) writechar(c);
  writechar(delim);
}

__int128_t digits(auto& i) {
  __int128_t res = 0;
  while (isdigit(*i)) res = 10 * res + *i++ - '0';
  return res;
}
__int128_t expr(auto& i);
__int128_t num(auto& i) {
  switch (*i) {
    case '+': return num(++i);
    case '-': return -num(++i);
    case '(': {
      __int128_t res = expr(++i);
      return ++i, res;
    }
    default: return digits(i);
  }
}
__int128_t term(auto& i) {
  __int128_t res = num(i);
  while (true) switch (*i) {
    case '*': res *= num(++i); break;
    case '/': res /= num(++i); break;
    default: return res;
  }
}
__int128_t expr(auto& i) {
  __int128_t res = term(i);
  while (true) switch (*i) {
    case '+': res += term(++i); break;
    case '-': res -= term(++i); break;
    default: return res;
  }
}

int main() {
  string s = getstring() + getstring();
  auto it = begin(s);
  putint(expr(it));
  writechar();
}
0