Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define all(x) begin(x),end(x)
- using namespace std;
- using ll = long long;
- const bool INTERACTIVE = false;
- const bool BINARY = false;
- const bool GENERATE = false;
- namespace binary_io {
- enum {
- BIG_ENDIAN,
- LITTLE_ENDIAN,
- UNDEF
- };
- int get_big(const char *buff) {
- int ans = 0;
- for (int i = 0; i < 4; i++) {
- ans = (ans << 8) ^ uint8_t(buff[i]);
- }
- return ans;
- }
- int get_little(char *buff) {
- swap(buff[0], buff[3]);
- swap(buff[1], buff[2]);
- int res = get_big(buff);
- swap(buff[0], buff[3]);
- swap(buff[1], buff[2]);
- return res;
- }
- pair<int, int> get_int(ifstream &in, int type) {
- char buff[4];
- in.read(buff, 4);
- int resultType = type;
- if (type == UNDEF) {
- if (abs(get_big(buff)) < abs(get_little(buff))) {
- resultType = BIG_ENDIAN;
- } else {
- resultType = LITTLE_ENDIAN;
- }
- }
- int res = 0;
- if (resultType == BIG_ENDIAN) {
- res = get_big(buff);
- } else {
- res = get_little(buff);
- }
- return {res, resultType};
- }
- void print_int(ofstream &out, int val, int type) {
- char buff[4];
- for (int i = 0; i < 4; i++) {
- if (type == BIG_ENDIAN) {
- buff[3 - i] = char(val & 255);
- } else {
- buff[i] = char(val & 255);
- }
- val >>= 8;
- }
- out.write(buff, 4);
- }
- void generate_output(ofstream &out) {
- int type = BIG_ENDIAN;
- int n = 5;
- vector<int> values = {-1, -2, -3, -4, -5};
- print_int(out, n, type);
- for (int val: values) {
- print_int(out, val, type);
- }
- }
- };
- template<typename InType, typename OutType>
- void solve(InType &in, OutType &out) {
- double a, b, c;
- in >> a >> b >> c;
- if (a == 0) {
- out << 1 << endl;
- out << -c / b << endl;
- return;
- }
- double D = b * b - 4 * a * c;
- if (D < -1e-9) {
- out << 0 << endl;
- return;
- }
- double x1 = (-b - sqrt(D)) / (2 * a);
- out << fixed << setprecision(15);
- if (abs(D) < 1e-9) {
- out << 1 << endl;
- out << x1 << endl;
- return;
- }
- double x2 = (-b + sqrt(D)) / (2 * a);
- out << 2 << endl;
- out << x1 << endl;
- out << x2 << endl;
- }
- int main() {
- ios_base::sync_with_stdio(false);
- if (INTERACTIVE) {
- solve(cin, cout);
- exit(0);
- }
- ifstream in;
- ofstream out;
- if (INTERACTIVE) {
- in.clear();
- out.clear();
- } else if (BINARY) {
- in = ifstream("input.bin", ios::binary);
- out = ofstream("output.bin", ios::binary);
- } else {
- in = ifstream("input.txt");
- out = ofstream("output.txt");
- }
- in.tie(nullptr);
- out.tie(nullptr);
- if (BINARY) {
- if (GENERATE) {
- ofstream o("input.bin", ios::binary);
- binary_io::generate_output(o);
- o.close();
- } else {
- solve(in, out);
- }
- } else {
- solve(in, out);
- }
- in.close();
- out.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement