• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

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

武飞扬头像
执 梗
帮助1

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;
}
学新通

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgcahic
系列文章
更多 icon
同类精品
更多 icon
继续加载