작성일 :

문제 링크

21354번 - Äpplen och päron

설명

두 사람의 과일 판매 수익을 비교하여 더 많이 번 사람을 구하는 문제입니다.


접근법

Axel은 사과를 7크로나에, Petra는 배를 13크로나에 판매합니다.

각자의 수익을 계산한 뒤 비교하여 더 큰 쪽의 이름을 출력하고, 같으면 lika를 출력합니다.



Code

C#

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

class Program {
  static void Main() {
    var p = Array.ConvertAll(Console.ReadLine()!.Split(), int.Parse);
    var axel = p[0] * 7;
    var petra = p[1] * 13;
    if (axel > petra) Console.WriteLine("Axel");
    else if (axel < petra) Console.WriteLine("Petra");
    else Console.WriteLine("lika");
  }
}

C++

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

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

  int a, p; cin >> a >> p;
  int axel = a * 7;
  int petra = p * 13;
  if (axel > petra) cout << "Axel\n";
  else if (axel < petra) cout << "Petra\n";
  else cout << "lika\n";

  return 0;
}