結果

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

テストケース

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

ソースコード

diff #

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

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string a, b;
  cin >> a >> b;
  a += b;
  auto it = begin(a);
  cout << expr(it) << '\n';
}
0