[백준 11520] And Then There Was 5 (C#, C++) - soo:bak
작성일 :
문제 링크
설명
π에서 특정 위치 이후 처음 등장하는 숫자 D의 위치와 그 이후 처음 등장하는 5의 위치를 찾는 문제입니다. 정의상 해당 위치의 숫자는 항상 D와 5이므로 실제 π의 자리를 계산할 필요가 없습니다.
접근법
각 테스트케이스마다 입력된 D와 5를 그대로 출력합니다.
Code
C#
1
2
3
4
5
6
7
8
9
10
11
12
using System;
class Program {
static void Main() {
var t = int.Parse(Console.ReadLine()!);
for (var i = 0; i < t; i++) {
var parts = Console.ReadLine()!.Split();
var d = int.Parse(parts[1]);
Console.WriteLine($"{d} 5");
}
}
}
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t; cin >> t;
for (int i = 0; i < t; i++) {
int p, d; cin >> p >> d;
cout << d << " 5\n";
}
return 0;
}