Submission #206690

# Submission time Handle Problem Language Result Execution time Memory
206690 2020-03-04T14:29:16 Z Ziel Chessboard (IZhO18_chessboard) C++17
0 / 100
5 ms 376 KB
// ~maqsat~

// #pragma GCC target ("avx2")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)
#define ever ;;

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T>
inline void cmin(T &a, T b) { a = min(a, b); }
template<class T>
inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e6 + 123;
const ll MOD = 1e9 + 7;
const ll INF = 1e15 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

#define int ll

inline ll calc(int len, int n, int q) {
    if (!q) {
        ll area = len * len;
        ll fi = ((n / len) + 1) / 2;
        ll se = (n / len) / 2;

        return ((n / len + 1) / 2 * fi * area) + ((n / len / 2) * se * area);
    }
    else {
        ll area = len * len;
        ll fi = ((n / len) + 1) / 2;
        ll se = (n / len) / 2;

        return ((n / len + 1) / 2 * se * area) + ((n / len / 2) * fi * area);
    }
}

main() {
#ifdef ZVER
    cerr << "Ready\n";
#endif
    fre("");
    ACCELERATE;

    int n, k;
    cin >> n >> k;

    if (!k) {
        ll ans = INF;
        for (int len = 1; len < n; len++) {
            if (n % len == 0) {
                ll x = calc(len, n, 0);
                ll y = calc(len, n, 1);

                cmin(ans, min(x, y));
                cout << len << ' ' << ' ' << min(x, y) << '\n';
            }
        }

        cout << ans << '\n';
    }

    return 0;
}

Compilation message

chessboard.cpp:72:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
chessboard.cpp: In function 'int main()':
chessboard.cpp:22:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
 #define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chessboard.cpp:76:5: note: in expansion of macro 'fre'
     fre("");
     ^~~
chessboard.cpp:22:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
 #define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chessboard.cpp:76:5: note: in expansion of macro 'fre'
     fre("");
     ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -