题解:P1421 小玉买文具

· · 题解

首先 1 元 9 角相当于 1.9 元,a 元 b 角相当于 a+0.1b 元。那么最多买的支数即 \left \lfloor \dfrac{a+0.1b}{1.9} \right \rfloor。

#include <iostream>

using namespace std;

const int N = 1e6 + 10;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a + b * 0.1) / 1.9;
    return 0;
}