大连大学2022年11月程序设计竞赛(同步赛) 原创 A题题解

题目描述

游戏泰拉瑞亚中,世界分为小世界、中世界和大世界。高度分别为1200,1800,2400格。
每个世界地层由以下规则生成:
1.太空(space):占10%地图高度
2.地表(surface):占10%地图高度
3.地下(underground):占10%地图高度
4.洞穴(cavern):占60%地图高度
5.地狱(underworld):占10%地图高度
最低处为地狱,最高处为太空。
我们用1,2,3分别表示小世界、中世界和大世界,世界高度从1开始。

输入描述:

op(1≤op≤3),t(1≤t≤5⋅10^5),分别表示世界的规模和询问次数。 接下来的ttt行,每行为一个整数h,表示高度,高度不会低于1,且不会超过世界最大高度。

输出描述:

输出t行,每行输出一个高度所对应的地层英文。

示例1

输入

1 5
1
120
840
960
1080

输出

underworld
cavern
underground
surface
space

以下为本人的题解

#include<bits/stdc++.h>
using namespace std;

const int N=10;
int n,op,t;

int main()
{
     int high;
     cin >> op >> t;
     high=(op+1)*600;
     int hight=high;
     int h1=0.1*high;
     int h2=0.7*high;
     int h3=0.8*high;
     int h4=0.9*high;
     
     while(t--)
     {
         cin >> n;
         if(n<h1)
         cout<<"underworld"<<endl;
         if(n>=h1 && n<h2)
         cout<<"cavern"<<endl;
         if(n>=h2 && n<h3)
         cout<<"underground"<<endl;
         if(n>=h3 && n<h4)
         cout<<"surface"<<endl;
         if(n>=h4)
         cout<<"space"<<endl;
     }
     
     return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值