※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※

 

이번에 볼 문제는 백준 14004번 문제인 ICPC이다.
문제는 아래 링크를 확인하자.

https://www.acmicpc.net/problem/14004 

 

14004번: ICPC

The input will consist of 4 integers A, B, C and D. They are respectively the rate a phone uses energy in Amperes (Coulombs per second), the rate in which a battery can be recharged in Amperes, the initial charge of the first battery in Coulombs and the in

www.acmicpc.net

배터리를 갈아끼우는 행동을 빼고 생각하면, 현재 배터리의 총 충전량은 C+D이고 이 총 충전량은 매 초마다 A-B씩 줄어든다.

 

총 충전량이 0이 되는 순간 핸드폰을 사용할 수 없게 되므로, (C+D)/(A-B)로 답을 구할 수 있다.

 

아래는 제출한 소스코드이다.

#include <iostream>
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	ll A, B, C, D; cin >> A >> B >> C >> D;
	cout << (C + D) / (A - B);
}
728x90

'BOJ' 카테고리의 다른 글

[BOJ 14006 // C++] Large Ping Pong Tournament  (0) 2022.05.12
[BOJ 14005 // C++] Small Ping Pong Tournament  (0) 2022.05.12
[BOJ 1013 // C++] Contact  (0) 2022.05.10
[BOJ 16650 // C++] Counting Stairs  (0) 2022.05.09
[BOJ 7562 // C++] 나이트의 이동  (0) 2022.05.08

+ Recent posts