Compile Error
/in/foo.cc: In function 'std::vector<std::__cxx11::basic_string<char> > sep(const std::string&)': /in/foo.cc:12:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 12 | for (int i = 0; i < s.length(); ++i) { | ~~^~~~~~~~~~~~ /in/foo.cc: In function 'std::vector<long long int> getxs(const std::string&)': /in/foo.cc:31:3: error: 'ranges' has not been declared 31 | ranges::reverse(res); | ^~~~~~ /in/foo.cc: In function 'void Main(const std::string&)': /in/foo.cc:57:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 57 | for (int i = 0; i < a.size(); ++i) { | ~~^~~~~~~~~~ /in/foo.cc:58:23: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 58 | for (int j = 0; j < b.size(); ++j) { | ~~^~~~~~~~~~
代码
#include <bits/extc++.h>
#define endl '\n'
typedef long long ll;
#define int ll
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
vector<string> sep(const string &s) {
vector<string> res;
res.emplace_back("");
for (int i = 0; i < s.length(); ++i) {
if (s[i] == '+') {
res.emplace_back("");
} else {
res.back() += s[i];
}
}
return res;
}
vector<int> getxs(const string &s) {
const auto &v = sep(s);
vector<int> res;
for (const auto &x: v) {
stringstream ss(x);
int a;
ss >> a;
res.emplace_back(a);
}
ranges::reverse(res);
return res;
}
void Main(const string &s) {
stringstream ss(s);
string frst, scnd;
char c;
while (c != '(') {
ss >> c;
}
while (c != ')') {
ss >> c;
frst += c;
}
frst.pop_back();
while (c != '(') {
ss >> c;
}
while (c != ')') {
ss >> c;
scnd += c;
}
scnd.pop_back();
const auto &a = getxs(frst), &b = getxs(scnd);
vector<int> fnl(a.size() * b.size());
for (int i = 0; i < a.size(); ++i) {
for (int j = 0; j < b.size(); ++j) {
fnl[i + j] += a[i] * b[j];
}
}
for (int i = (a.size() - 1) * (b.size() - 1) + 1; i; --i) {
fnl[i] && cout << fnl[i] << "a^" << i << "+";
}
cout << fnl[0] << endl
<< flush;
fflush(stdout);
}
// #define __CP_MULTI_TEST_CASES
signed main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
// int t = 1;
// #ifdef __CP_MULTI_TEST_CASES
// cin >> t;
// #endif
// while (t--) {
// Main();
// }
string s;
while (getline(cin, s)) {
Main(s);
}
return 0;
}
信息
- 递交者
- 类型
- 递交
- 题目
- P1000 云剪贴板
- 题目数据
- 下载
- 语言
- C++
- 递交时间
- 2025-07-14 20:59:54
- 评测时间
- 2025-07-14 20:59:54
- 评测机
- 分数
- 0
- 总耗时
- 0ms
- 峰值内存
- 0 Bytes