Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
- #pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt,tune=native")
- #pragma GCC target("avx,avx2")
- #pragma GCC target ("avx2")
- #pragma GCC optimize ("O3")
- #pragma GCC optimize ("unroll-loops")
- #pragma GCC optimize("Ofast")
- #include <iostream>
- using namespace std;
- struct Solution {
- static bool is_digit_num(char c) {
- return ( c>='0' && c<='9');
- }
- int checking(int n, int w, int h, float r, int lines_count) {
- float hOfRow = (float) h / (float) lines_count;
- long long Counter2 = (n - 1) / lines_count + 1;
- long long Counter1 = n / lines_count;
- float maxW = hOfRow * r;
- float minW = hOfRow;
- if (maxW * Counter1 < w || maxW * Counter2 < w) {
- return 1;
- }
- if (minW * Counter1 > w || minW * Counter2 > w) {
- return -1;
- }
- return 0;
- }
- void solve() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- long long t;
- cin >> t;
- long long n, w, h;
- float r;
- while (t--) {
- cin >> n >> w >> h >> r;
- long long left = 0;
- long long right = n + 1;
- while (right - left > 1) {
- long long mid = (left + right) / 2;
- long long result = checking(n, w, h, r, mid);
- if (result == -1)
- left = mid;
- else if(result == 1)
- right = mid;
- else{
- right=mid;
- break;
- }
- }
- long long lines_count = right;
- if(checking(n, w, h, r, right) == 0) {
- long long minCountInRow = n / right;
- long long maxCountInRow = minCountInRow;
- if (n % right != 0)
- maxCountInRow += 1;
- cout << right << ' ' << minCountInRow << ' ' << maxCountInRow << '\n';
- } else{
- cout << -1 << '\n';
- }
- }
- }
- };
- int main() {
- Solution solution;
- solution.solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement