2705: 练28.3 短信计费
内存限制:64 MB
时间限制:1.000 S
评测方式:文本比较
命题人:
提交:75
解决:18
题目描述
用手机发短信,一条短信资费为 $0.1$元,但限定一条短信的内容在 $70$ 个字以内(包括 $70$ 个字)。如果一次所发送的短信超过了 $70$ 个字,则会按照每 $70$ 个字一条短信的限制把它分割成多条短信发送。假设已经知道某人当月所发送的短信的字数,试统计一下他当月短信的总资费。
输入
第一行是整数 $n$($1≤n≤100$),表示当月发送短信的总次数,接着 $n$ 行每行一个整数(不超过 $1000$),表示每次短信的字数。
输出
输出一行,当月短信总资费,单位为元,精确到小数点后 $1$ 位。
样例输入 复制
10
39
49
42
61
44
147
42
72
35
46
样例输出 复制
1.3
提示
#include<bits/stdc++.h> using namespace std; double ans; int n,x; int main() { cin>>n; for(int i=1;i<=n;i++){ cin>>x; int y=x/70; if(x%70) y++; ans+=y*0.1; } printf("%.1lf",ans); return 0; }
#include<bits/stdc++.h> using namespace std; double ans; int n,x; int main() { cin>>n; for(int i=1;i<=n;i++){ cin>>x; int y=(x-1)/70+1; //减一加一法 ans+=y*0.1; } printf("%.1lf",ans); return 0; }