작성일 :

문제 링크

32314번 - Christmas Tree Adapter

설명

트리가 요구하는 전류 a와, 후보 어댑터의 전력 w, 전압 v가 주어졌을 때 어댑터의 전류 w/v가 a 이상이면 1, 아니면 0을 출력하는 문제입니다.


접근법

어댑터 전류 amp = w / v를 계산해 a와 비교하면 되는 단순한 문제입니다.



Code

C#

1
2
3
4
5
6
7
8
9
10
11
12
using System;

class Program {
  static void Main() {
    int a = int.Parse(Console.ReadLine()!);
    var p = Console.ReadLine()!.Split();
    int w = int.Parse(p[0]);
    int v = int.Parse(p[1]);
    int amp = w / v;
    Console.WriteLine(amp >= a ? 1 : 0);
  }
}

C++

1
2
3
4
5
6
7
8
9
10
11
12
#include <bits/stdc++.h>
using namespace std;

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

  int a, w, v; cin >> a >> w >> v;
  int amp = w / v;
  cout << (amp >= a ? 1 : 0) << "\n";
  return 0;
}

Tags: 32314, BOJ, C#, C++, 구현, 백준, 알고리즘

Categories: ,