LoginSignup
0
0

More than 1 year has passed since last update.

AI Programmerの作法 その19

Posted at

概要

AI Programmerの作法、調べてみた。
atcoderやってみた。

投入したソースコード

  • C++
  • X 円を払ってりんごを 1 個手に入れる。
    Y 円を払ってりんごを 3 個手に入れる。
    りんごをちょうど N 個手に入れるには最低何円必要ですか?

実行結果

X 円を払ってりんごを 1 個手に入れる。
Y 円を払ってりんごを 3 個手に入れる。
りんごをちょうど N 個手に入れるには最低何円必要ですか?

#include <iostream>
using namespace std;

int main() {
    
    int x, y, n;
    
    cin >> x >> y >> n;
    
    int ans = (n / 3) * y + (n % 3) * x;
    
    cout << ans << endl;
    
    return 0;
    
}

paiza.io

入力

10
25
10

実行結果

85

成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0