Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool is_digit_num(char c) {
- return (c>='0' && c<='9');
- }
- int check(int n, int w, int h, float r, int cnt_strip) {
- float hOfRow = (float) h / (float) cnt_strip;
- long long Counter1 = n / cnt_strip;
- long long Counter2 = (n - 1) / cnt_strip + 1;
- float maxW = hOfRow * r;
- float minW = hOfRow;
- if (minW * Counter1 > w || minW * Counter2 > w) {
- return -1;
- }
- if (maxW * Counter1 < w || maxW * Counter2 < w) {
- return 1;
- }
- return 0;
- }
- int main() {
- cin.tie(0);
- cout.tie(0);
- ios_base::sync_with_stdio(false);
- long long t;
- cin >> t;
- while (t--) {
- long long n, w, h;
- float r=0;
- cin >> n >> w >> h >> r;
- long long left = 0;
- long long right = n + 1;
- while (right - left > 1) {
- long long m = (left + right)/2;
- long long result = check(n, w, h, r, m);
- if (result == -1)
- left = m;
- else if(result == 1)
- right = m;
- else{
- right=m;
- break;
- }
- }
- long long count_strip = right;
- if(check(n, w, h, r, count_strip) == 0) {
- long long minCountInRow = n / count_strip;
- long long maxCountInRow = minCountInRow;
- if (n % count_strip != 0)
- maxCountInRow += 1;
- cout << count_strip << ' ' << minCountInRow << ' ' << maxCountInRow << '\n';
- }
- else{
- cout<<-1<<endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement