ZeroJudge D827: Buying Pencils

The price of a pencil is $5 each, and a dozen (12 pencils) costs $50. Xiao Ming needs to buy a pencil for each student in the class. How much money does he need to spend? Since Xiao-Ming cares about the environment, he will not buy any unnecessary items just to save money. In other words, the number of pencils Xiao-Ming buys must be equal to the number of students in the class.

Sample Inputs/Outputs

Sample Input(s)Sample Output(s)
The input consists of only one line, containing the number of students in Xiao Ming's class, denoted by N (1 ≤ N ≤ 200).Please output a single number representing the total amount of money spent on this purchase.
42180
1155

Thought Process

Divide the number of students in the class by 12 to determine how many dozen pencils to buy. Then, calculate the remainder of the division to determine how many individual pencils to buy.

Sample Code-ZeroJudge D827: Buying Pencils

#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  cout << ((N/12)*50) + ((N%12)*5) << endl;
}

//Z.O.J. D827
//Dr. SeanXD

Comments