3104:练18.4 计算邮资(C、C++、python)

577 篇文章 3 订阅

3104:练18.4 计算邮资

信息学奥赛一本通-编程启蒙(C++版)在线评测系统

练 18.4 计算邮资

1052:计算邮资

信息学奥赛一本通(C++版)在线评测系统

1052:计算邮资-信息学奥赛一本通

1052:计算邮资-信息学奥赛一本通_哔哩哔哩_bilibili

1.4_14计算邮资(c语言)_哔哩哔哩_bilibili

1052:计算邮资_哔哩哔哩_bilibili

《信息学奥赛一本通》题解_1052_计算邮资_哔哩哔哩_bilibili




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 提高组 初赛 四、阅读程序写结果 习题集(五)NOIP2006-NOIP2007_该程序会输出( )。 a: 6 28 496 8128 33550000 b:6 28 496 81-CSDN博客

NOIP 提高组 初赛 四、阅读程序写结果 习题集(六)NOIP2008-NOIP2009

NOIP 提高组 初赛 四、阅读程序写结果 习题集(六)NOIP2008-NOIP2009-CSDN博客

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

【初赛】「阅读程序」题答v1.0_阅读程序题怎么做-CSDN博客

  • 7
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dllglvzhenfeng

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值