結果
問題 | No.265 数学のテスト |
ユーザー | firiexp |
提出日時 | 2019-12-27 12:40:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,759 bytes |
コンパイル時間 | 700 ms |
コンパイル使用メモリ | 87,100 KB |
最終ジャッジ日時 | 2024-11-14 22:00:27 |
合計ジャッジ時間 | 1,402 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:28:21: error: return type 'using ar = struct std::array<long long int, 11>' {aka 'struct std::array<long long int, 11>'} is incomplete 28 | ar factor(state &cur){ | ^ main.cpp: In function 'void factor(state&)': main.cpp:29:48: error: invalid use of incomplete type 'using ar = struct std::array<long long int, 11>' {aka 'struct std::array<long long int, 11>'} 29 | if(*cur == 'x' || isdigit(*cur)) return num(cur); | ~~~^~~~~ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_map.h:63, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/map:61, from main.cpp:5: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/tuple:1595:45: note: declaration of 'using ar = struct std::array<long long int, 11>' {aka 'struct std::array<long long int, 11>'} 1595 | template<typename _Tp, size_t _Nm> struct array; | ^~~~~ main.cpp:31:8: error: variable 'ar ret' has initializer but incomplete type 31 | ar ret = add(cur); | ^~~ main.cpp:31:17: error: invalid use of incomplete type 'using ar = struct std::array<long long int, 11>' {aka 'struct std::array<long long int, 11>'} 31 | ar ret = add(cur); | ~~~^~~~~ /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/tuple:1595:45: note: declaration of 'using ar = struct std::array<long long int, 11>' {aka 'struct std::array<long long int, 11>'} 1595 | template<typename _Tp, size_t _Nm> struct array; | ^~~~~ main.cpp: At global scope: main.cpp:40:18: error: return type 'using ar = struct std::array<long long int, 11>' {aka 'struct std::array<long long int, 11>'} is incomplete 40 | ar num(state &cur){ | ^ main.cpp:40:4: error: ambiguating new declaration of 'void num(
ソースコード
#include <limits> #include <iostream> #include <algorithm> #include <iomanip> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> #include <cmath> static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using u64 = unsigned long long; using namespace std; template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; using ar = array<ll, 11>; using state = string::const_iterator; ar num(state &cur); ar add(state &cur); ar factor(state &cur){ if(*cur == 'x' || isdigit(*cur)) return num(cur); cur++; cur++; ar ret = add(cur); for (int i = 0; i < 10; ++i) { ret[i] = ret[i+1]*(i+1); } ret[10] = 0; cur++; return ret; } ar num(state &cur){ ar ret{}; if(isdigit(*cur)) ret[0] = *cur-'0'; else ret[1] = 1; cur++; return ret; } ar mul(state &cur){ ar ret = factor(cur); while(true){ if(*cur == '*'){ cur++; ar rett = factor(cur); if(rett[0]){ for (int i = 0; i < 11; ++i) ret[i] *= rett[0]; }else { for (int i = 9; i >= 0; --i) ret[i+1] = ret[i]; ret[0] = 0; } }else break; } return ret; } ar add(state &cur){ ar ret = mul(cur); while(true){ if(*cur == '+'){ cur++; ar x = mul(cur); for (int i = 0; i < 11; ++i) ret[i] += x[i]; }else break; } return ret; } int main() { int n, d; string s; cin >> n >> d >> s; state ss = s.begin(); auto ret = add(ss); for (int i = 0; i < d+1; ++i) { if(i) printf(" "); printf("%lld", ret[i]); } puts(""); return 0; }