Submission #6490617


Source Code Expand

Copy
#include<bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {


  int64 S;
  cin >> S;

  const int64 LIM = (int) 1e9;

  int64 X[3], Y[3];
  X[0] = 0, Y[0] = 0;


  int64 sa = infll, pos = 0;
  for(int64 X1 = 1; X1 <= LIM; X1 += 15) {
    int64 Y2 = (S + X1 - 1) / X1;
    if(Y2 <= LIM && chmin(sa, (X1 * Y2) - S)) {
      pos = X1;
    }
  }
  for(int64 X1 = LIM; X1 >= 1; X1 -= 15) {
    int64 Y2 = (S + X1 - 1) / X1;
    if(Y2 <= LIM && chmin(sa, (X1 * Y2) - S)) {
      pos = X1;
    }
  }


  X[1] = pos;
  Y[2] = (S + X[1] - 1) / pos;

  int64 rest = X[1] * Y[2] - S;

  Y[1] = 1;
  X[2] = rest;


  for(int i = 0; i < 3; i++) {
    if(i) cout << " ";
    cout << X[i] << " " << Y[i];
  }
  cout << endl;
}

Submission Info

Submission Time
Task A - Triangle
User ei13333
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2805 Byte
Status
Exec Time 1410 ms
Memory 256 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt
All 400 / 400 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
01-01.txt 1406 ms 256 KB
01-02.txt 1407 ms 256 KB
01-03.txt 1406 ms 256 KB
01-04.txt 1380 ms 256 KB
01-05.txt 1374 ms 256 KB
01-06.txt 1378 ms 256 KB
01-07.txt 1404 ms 256 KB
01-08.txt 1367 ms 256 KB
01-09.txt 1366 ms 256 KB
01-10.txt 1367 ms 256 KB
01-11.txt 1367 ms 256 KB
01-12.txt 1366 ms 256 KB
01-13.txt 1365 ms 256 KB
sample-01.txt 1410 ms 256 KB
sample-02.txt 1406 ms 256 KB
sample-03.txt 1395 ms 256 KB