0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-09 16:18:49 +00:00

#1555. 【2022 正睿 CSP 七连测 Day3】Convert

https://sjzezoj.com/submission/60760
This commit is contained in:
Baoshuo Ren 2022-10-18 18:13:45 +08:00
parent c6e9fefa08
commit b233e7ae1d
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
202 changed files with 730 additions and 0 deletions

127
S2OJ/1555/1555.cpp Normal file
View File

@ -0,0 +1,127 @@
#include <iostream>
#include <algorithm>
#include <complex>
#include <string>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
using complex = std::complex<long long>;
complex to_complex(std::string str) {
complex res{0ll, 0ll};
if (str.empty()) return res;
if (str[0] == '-') {
auto pos_pos = str.find('+', 1),
pos_neg = str.find('-', 1);
if (pos_pos == std::string::npos && pos_neg == std::string::npos) {
// 仅实部 or 仅虚部
if (str.back() == 'i') {
// 仅虚部
auto str_imag = str.substr(1, str.size() - 2);
res.imag(-std::stoll(str_imag.empty() ? "1" : str_imag));
} else {
// 仅实部
res.real(-std::stoll(str.substr(1)));
}
} else if (pos_pos == std::string::npos) {
// 虚部是负数
auto str_real = str.substr(1, pos_neg - 1),
str_imag = str.substr(pos_neg + 1, str.size() - 1 - (pos_neg + 1));
res.real(-std::stoll(str_real));
res.imag(-std::stoll(str_imag.empty() ? "1" : str_imag));
} else {
// 虚部是正数
auto str_real = str.substr(1, pos_pos - 1),
str_imag = str.substr(pos_pos + 1, str.size() - 1 - (pos_pos + 1));
res.real(-std::stoll(str_real));
res.imag(std::stoll(str_imag.empty() ? "1" : str_imag));
}
} else {
auto pos_pos = str.find('+', 1),
pos_neg = str.find('-', 1);
if (pos_pos == std::string::npos && pos_neg == std::string::npos) {
// 仅实部 or 仅虚部
if (str.back() == 'i') {
// 仅虚部
auto str_imag = str.substr(0, str.size() - 1);
res.imag(std::stoll(str_imag.empty() ? "1" : str_imag));
} else {
// 仅实部
res.real(std::stoll(str));
}
} else if (pos_pos == std::string::npos) {
// 虚部是负数
auto str_real = str.substr(0, pos_neg),
str_imag = str.substr(pos_neg + 1, str.size() - 1 - (pos_neg + 1));
res.real(std::stoll(str_real));
res.imag(-std::stoll(str_imag.empty() ? "1" : str_imag));
} else {
// 虚部是正数
auto str_real = str.substr(0, pos_pos),
str_imag = str.substr(pos_pos + 1, str.size() - 1 - (pos_pos + 1));
res.real(std::stoll(str_real));
res.imag(std::stoll(str_imag.empty() ? "1" : str_imag));
}
}
return res;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
std::string s;
cin >> s;
auto num = to_complex(s);
std::vector<bool> ans;
while (num.real() || num.imag()) {
bool r = (num.real() + num.imag()) % 2;
ans.emplace_back(r);
long long q_r = (num.real() - r - num.imag()) / -2;
long long q_i = q_r - num.imag();
num.real(q_r);
num.imag(q_i);
}
if (ans.empty()) ans.emplace_back(0);
std::reverse(ans.begin(), ans.end());
for (auto x : ans) {
cout << x;
}
cout << endl;
return 0;
}

BIN
S2OJ/1555/data/Convert1.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert10.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert100.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert100.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert11.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert12.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert13.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert14.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert15.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert16.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert17.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert18.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert19.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert20.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert21.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert21.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert22.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert22.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert23.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert23.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert24.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert24.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert25.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert25.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert26.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert26.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert27.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert27.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert28.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert28.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert29.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert29.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert3.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert30.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert30.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert31.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert31.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert32.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert32.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert33.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert33.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert34.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert34.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert35.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert35.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert36.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert36.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert37.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert37.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert38.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert38.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert39.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert39.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert4.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert40.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert40.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert41.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert41.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert42.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert42.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert43.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert43.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert44.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert44.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert45.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert45.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert46.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert46.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert47.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert47.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert48.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert48.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert49.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert49.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert5.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert50.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert50.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert51.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert51.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert52.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert52.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1555/data/Convert53.ans (Stored with Git LFS) Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More