[백준 26532] Acres (C#, C++) - soo:bak
작성일 :
문제 링크
설명
간단한 사칙연산 문제입니다. 
우선, 주어진 땅의 크기를 제곱 야드로 계산합니다. 
계산된 제곱 야드를 Acre 로 변환한 후, 5 로 나누어 필요한 옥수수 씨앗의 봉지 수를 계산합니다. 
이 때 만약, 나머지가 있다면 올림합니다. 
최종적으로 필요한 옥수수 씨앗의 봉지 수를 출력합니다. 
Code
[ C# ] 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
namespace Solution {
  class Program {
    static void Main(string[] args) {
      var input = Console.ReadLine()?.Split();
      var width = int.Parse(input![0]);
      var length = int.Parse(input![1]);
      var sqYard = width * length;
      var acreToYard = 4840.0;
      var cntCorn = 5.0;
      var acres = (double)sqYard / acreToYard;
      var bags = (int)Math.Ceiling(acres / cntCorn);
      Console.WriteLine($"{bags}");
    }
  }
}
[ C++ ] 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int width, length; cin >> width >> length;
  int sqYard = width * length;
  double acreToYard = 4840.0;
  double cntCorn = 5.0;
  double acres = (double)sqYard / acreToYard;
  int bags = ceil(acres / cntCorn);
  cout << bags << "\n";
  return 0;
}