結果
| 問題 |
No.8062 A + B
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2020-04-01 21:55:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,882 bytes |
| コンパイル時間 | 1,507 ms |
| コンパイル使用メモリ | 168,656 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-27 10:43:33 |
| 合計ジャッジ時間 | 2,048 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 |
コンパイルメッセージ
main.cpp:38:19: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
38 | __int128_t digits(auto& i) {
| ^~~~
main.cpp:43:17: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
43 | __int128_t expr(auto& i);
| ^~~~
main.cpp:44:16: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
44 | __int128_t num(auto& i) {
| ^~~~
main.cpp:55:17: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
55 | __int128_t term(auto& i) {
| ^~~~
main.cpp:63:17: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
63 | __int128_t expr(auto& i) {
| ^~~~
ソースコード
#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(' ');
s += getstring();
auto it = begin(s);
putint(expr(it));
writechar();
}
risujiroh