반응형
https://www.acmicpc.net/problem/3507
3507번: Automated Telephone Exchange
In St Petersburg phone numbers are formatted as “XXX–XX–XX”, where the first three digits represent index of the Automated Telephone Exchange (ATE). Each ATE has exactly 10 000 unique phone numbers. Peter has just bought a new flat and now he wants
www.acmicpc.net
수학문제였습니다.
📕 풀이방법
📔 입력 및 초기화
n을 선언 후 입력받습니다.
📔 풀이과정
3자리 수인 n을 2자리의 수 2개로 나눌 수 있는 경우의 수를 물어보는 문제입니다. 두 자리 수의 합은 99 + 99 = 198이 최대입니다. 따라서 이를 초과하면 무조건 0이 답입니다. 그 외의 경우는 두 자리로 나타낼 수 있는 가장 큰 수 99를 이용하면 됩니다. 99 - (n - 99) + 1이 이 순서에 상관없이 숫자들의 조합을 뽑는 경우의 수가 됩니다.
📔 정답출력
조건에 따라 적절히 출력해줍니다.
📕 Code
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
cin >> n;
if(n > 198) cout << 0;
else cout << 99 - (n - 99) + 1;
}
📕 Test Case
몇 가지 반례를 직접 작성해 보았습니다.
input
200
답 0
input
199
답 0
input
198
답 1
'Algorithm > Math' 카테고리의 다른 글
(C++) - 백준(BOJ) 6696 : Too Much Water (0) | 2021.12.28 |
---|---|
(C++) - 백준(BOJ) 8674 : Tabliczka (0) | 2021.12.21 |
(C++) - 백준(BOJ) 1975: Number Game (0) | 2021.11.22 |
(C++) - 백준(BOJ) 1703 : 생장점 (0) | 2021.11.19 |
(C++) - 백준(BOJ) 21335 : Another Eruption (0) | 2021.11.12 |