結果
| 問題 |
No.8062 A + B
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2020-04-01 21:51:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 891 bytes |
| コンパイル時間 | 1,476 ms |
| コンパイル使用メモリ | 166,960 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-27 10:34:36 |
| 合計ジャッジ時間 | 2,020 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 3 |
コンパイルメッセージ
main.cpp:4:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
4 | int digits(auto& i) {
| ^~~~
main.cpp:9:10: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
9 | int expr(auto& i);
| ^~~~
main.cpp:10:9: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
10 | int num(auto& i) {
| ^~~~
main.cpp:21:10: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
21 | int term(auto& i) {
| ^~~~
main.cpp:29:10: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
29 | int expr(auto& i) {
| ^~~~
ソースコード
#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';
}
risujiroh