C#/백준 알고리즘
2022.01.25 [백준] C# 분수 찾기
ian's coding
2022. 1. 25. 16:46
728x90
반응형
풀이 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
using System;
class Program{
static void Main(){
int n = int.Parse(Console.ReadLine());
int a = 1;
int cnt = 1;
while(n>a){
cnt++;
a+=cnt;
}
if(cnt%2==0){
Console.Write($"{cnt-(a-n)}/{a-n+1}");
}else{
Console.Write($"{a-n+1}/{cnt-(a-n)}");
}
}
}
|
cs |
728x90
반응형