第十三届蓝桥杯 Java C组省赛 C 题——纸张尺寸(AC)

1.纸张尺寸

1.题目描述

在 ISO 国际标准中定义了 A0 纸张的大小为 1189mm × 841mm, 将 A0 纸 沿长边对折后为 A1 纸, 大小为 841mm × 594mm, 在对折的过程中长度直接取 下整 (实际裁剪时可能有损耗)。将 A1 纸沿长边对折后为 A2 纸, 依此类推。

输入纸张的名称, 请输出纸张的大小。

2.输入格式

输入一行包含一个字符串表示纸张的名称, 该名称一定是 A0、A1、A2、 A3、A4、A5、A6、A7、A8、A9 之一。

3.输出格式

输出两行,每行包含一个整数,依次表示长边和短边的长度。

4.样例输入

A1

5.样例输出

841
594

6.原题链接

纸张尺寸

2.解题思路

签到题,根据题意模拟即可,注意每次折半选的是较长的一边。

3.Ac_code

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int, int> PII;
#define pb(s) push_back(s);
#define SZ(s) ((int)s.size());
#define ms(s,x) memset(s, x, sizeof(s))
#define all(s) s.begin(),s.end()
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const int N = 200010;


void solve()
{
	std::vector<PII> a(10);
	a[0] = {1189, 841};
	for (int i = 1; i < 10; ++i) {
		int l = a[i - 1].first, r = a[i - 1].second;
		if (l > r) {
			a[i].first = l / 2;
			a[i].second = r;
		} else {
			a[i].first = r / 2;
			a[i].second = l;
		}
	}
	string s;
	cin >> s;
	int x = s[1] - '0';
	int l = a[x].first, r = a[x].second;
	if(l>r){
		cout<<l<<'\n';
		cout<<r<<'\n';
	}else{
		cout<<r<<'\n';
		cout<<l<<'\n';
	}
}
int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1;
	while (t--)
	{
		solve();
	}
	return 0;
}
  • 136
    点赞
  • 132
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 117
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

执 梗

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

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

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

打赏作者

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

抵扣说明:

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

余额充值