RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0661

Transforming Pairs

Gold I 골드 I
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Answer \(Q\) (\(1\le Q\le 10^5\)) independent queries each of the following form:

You are given four integers \(a,b,c,d\) (\(-10^{18}\le a,b,c,d\le 10^{18}\)). In one
operation you can either do \(a\mathrel{+}=b\), or \(b\mathrel{+}=a\). Determine
the minimum number of operations to transform \((a,b)\) into \((c,d)\), or if it is
impossible to do so, output \(-1\).

Problem credits: Benjamin Qi

제약

SCORING

  • Input 2: \(|a|, |b|, |c|,|d|\le 10\)
  • Input 3: \(a,b\ge 0\)
  • Input 4: \(a \geq 0 \geq b\)
  • Input 5: \(a \leq 0 \leq b\)
  • Input 6: \(a,b\le 0\)
  • Input 7: \(c,d\ge 0\)
  • Input 8: \(c \geq 0 \geq d\)
  • Input 9: \(c \leq 0 \leq d\)
  • Input 10: \(c,d\le 0\)
  • Inputs 11-14: \(Q \leq 10^3\)
  • Inputs 15-19: No additional constraints.

Problem credits: Benjamin Qi

입력 형식

The first line contains \(Q\).

The next \(Q\) lines each contain four integers \(a,b,c,d\).

출력 형식

The answer for each query on a separate line.

예제 1
입력
4
5 -3 -1 -3
5 3 5 2
5 3 8 19
5 3 5 3
출력
2
-1
3
0
설명

First query: \((5,-3)\to (2,-3)\to (-1,-3)\)

Second query: Impossible.

Third query: \((5,3) \to (8, 3) \to (8, 11) \to (8, 19)\)

Fourth query: No operations necessary.

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2024-2025 > February > Platinum

태그

평가 및 의견

Transforming Pairs

개요
출제자 난이도 Gold I 골드 I 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Transforming Pairs

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8