1.12 02: SMS billing

Description
Send a text message with a mobile phone. The charge for a text message is 0.1 yuan, but the content of a text message is limited to 70 characters (including 70 characters). If you send more than 70 text messages at a time, it will be divided into multiple text messages and sent according to the limit of one text message per 70 words. Assuming that you already know the number of text messages you sent in the current month, try to count the total charges for your text messages that month.

Input The
first line is an integer n, which represents the total number of SMS messages sent in the current month, and then an integer in each line of n lines represents the number of words in each message.
Output
Output one line, the total cost of SMS in the current month, in yuan, accurate to one decimal place.
Sample input
10
39
49
42
61
44
147
42
72
35
46
Sample output
1.3

#include <iostream>
#include <cstdio>
using namespace std;
float ans = 0.0;
int num(int n)
{
    
    
	int t;
	if(n%70 == 0)
	{
    
    
		t =  n/70;
	} else{
    
    
		t = n/70+1;
	}
	return t;
}
int main()
{
    
    
	int sum=0;
	int n,temp;
	float cost;
	cin >> n;
	for(int i=0;i<n;i++)
	{
    
    
		scanf("%d", &temp);
		sum += num(temp);
	} 
	cost = sum*0.1;
	printf("%.1f", cost);
	return 0;
} 

Guess you like

Origin blog.csdn.net/yansuifeng1126/article/details/113102811