3104:练18.4 计算邮资
练 18.4 计算邮资
1052:计算邮资
1052:计算邮资-信息学奥赛一本通
C语言代码:
#include<stdio.h>
#include<stdlib.h>
int main()
{
//sum=8
//重量在1000克以内(包括1000克), 基本费8元。
//这样写比较简单
int a,sum=8;
char b;
//输入一行,包含整数和一个字符,
//以一个空格分开,分别表示重量(单位为克)和是否加急。
scanf("%d %c",&a,&b);
if(a>1000)
{
{
if((a-1000)%500==0)
{
sum+=(a-1000)/500*4;
}
else
{
sum+=((a-1000)/500+1)*4;
}
}
}
if(b=='y')
{
sum+=5;
}
printf("%d",sum);
return 0;
}
C++代码:
/*
NOI / 1.4编程基础之逻辑表达式与条件分支
14计算邮资 2021.11.17 AC
http://noi.openjudge.cn/ch0104/solution/31398502/
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
int x,s,y,t;
char ch;
cin>>x>>ch;
if(ch=='y') s=5;
else s=0;
if(x<=1000) s+=8;
else{
y=x-1000;
if(y%500==0) t=y/500;
else t=y/500+1;
s+=8+t*4;
}
cout<<s;
return 0;
}
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n,ans=8;
char a;
cin>>n>>a;
if(a=='y'){
ans+=5;
}
if(n>1000){
n-=1000;
cout<<ans+4*ceil(n*1.0/500);
return 0;
}
cout<<ans;
return 0;
}
python3代码:
"""
1.4编程基础之逻辑表达式与条件分支 14 计算邮资
http://noi.openjudge.cn/ch0104/14/
https://blog.csdn.net/yigezzchengxuyuan/article/details/86651658
"""
import math
x, y = map(str, input().split())
if y == "y":
if int(x) <= 1000:
print(13)
else:
print(8 + math.ceil((int(x)-1000)/500)*4 + 5)
if y == "n":
if int(x) <= 1000:
print(8)
else:
print(8 + math.ceil((int(x)-1000)/500)*4)
weight,hurry=input().split()
weight=int(weight)
sum=8
if weight>1000:
y=weight-1000
sum+=((y-1)//500+1)*4
if hurry=='y':
sum+=5
print(sum)
NOIP 提高组 初赛 四、阅读程序写结果 习题集(五)NOIP2006-NOIP2007
NOIP 提高组 初赛 四、阅读程序写结果 习题集(六)NOIP2008-NOIP2009
NOIP 提高组 初赛 四、阅读程序写结果 习题集(七)NOIP2010-NOIP2011
NOIP 提高组 初赛 四、阅读程序写结果 习题集(七)NOIP2010-NOIP2011_noip初赛114514-CSDN博客
NOIP 提高组 初赛 四、阅读程序写结果 习题集(八)NOIP2012-NOIP2013
NOIP 提高组 初赛 四、阅读程序写结果 习题集(八)NOIP2012-NOIP2013_data[h-1]=data[h-1]+data[h]-CSDN博客
NOIP 提高组 初赛 四、阅读程序写结果 习题集(九)NOIP2014-NOIP2015
NOIP 提高组 初赛 四、阅读程序写结果 习题集(九)NOIP2014-NOIP2015_noip2014阅读程序-CSDN博客
C++信息学奥赛题目归类:初赛普及组阅读程序写结果题
C++信息学奥赛题目归类:初赛普及组阅读程序写结果题_#include <iostream> using namespace std; int n, m;-CSDN博客
【初赛】「阅读程序」题答v1.0