Holes(ACM ICPC 2008–2009, NEERC, Northern Subregional Contest Problem H)

本文介绍了一款用于生成特定数量纸张打孔的艺术安装程序。该程序通过输入指定的打孔数量,输出一个最小的非负整数,当这个数字被一种特殊的切割打字机打印时,会在纸上留下相应数量的打孔。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Description

Input file: holes.in

Output file: holes.out

Time limit: 3 seconds

Memory limit: 256 megabytes

You may have seen a mechanic typewriter — such devices were widespread just 15 years ago, beforecomputers replaced them. It is a very simple thing. You strike a key on the typewriter keyboard, thecorresponding type bar rises, and the metallic letter molded into the type bar strikes the paper. Theart of typewriter typing, however, is more complicated than the art of computer typing. You shouldstrike keys with some force otherwise the prints will not be dark enough. Also you should not overdo itotherwise the paper will be damaged.

Imagine a typewriter with very sharp letters, which cut the paper instead of printing. It is clear thatdigit 0 being typed on the typewriter makes a nice hole in the paper and you receive a small paper ovalas a bonus. The same happens with some other digits: 4, 6, 9 produce one hole, and 8 produces twotouching holes. The remaining digits just cut the paper without making holes.

The Jury thinks about some exhibition devoted to the oncoming jubilee of Pascal language. One of theideas is to make an art installation, consisting of an empty sheet of paper with exactly h (0 ≤ h ≤ 510)holes made by typing a non-negative integer number on the cutting typewriter described above. Thenumber must be minimal possible and should not have leading zeroes. Unluckily we are too busy withpreparing the ACM quarter- and semifinals, so we need your help and ask you to write a computerprogram to generate the required number.

Input

A single integer number h — the number of holes.

Output

The integer number which should be typed.

Sample Input

0

Sample Output

1

Sample Input

1

Sample Output

0

Sample Input

15

Sample Output

48888888

Sample Input

70

Sample Output

88888888888888888888888888888888888

题解:读懂,就会了吧。。。。

代码如下:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#define For(i,n) for(int i=0;i<n;i++)
#define mem(a) memset(a,0,sizeof(a))
using namespace std;
const int maxn = 600;
const double Pi = acos(-1);
const int INF = 0x3f3f3f3f;
int main()
{
    freopen("holes.in","r",stdin);
    freopen("holes.out","w",stdout);
    int a[maxn] = {0};
    int cnt = 0;
    int n;
    bool flag = false;
    while(cin >> n)
    {
        cnt = 0;
        flag = false;
        mem(a);
        if(n < 2)
            flag = true;
        while(n>=2)
        {
            a[cnt++] = 8;
            n-=2;
        }
        if(flag)
        {
            if(n == 0)
                a[cnt++] = 1;
            else
            {
                a[cnt++] = 0;
            }
        }
        else
        {
            if(n)
                a[cnt++] = 4;
        }
        for(int i=cnt-1; i>=0; i--)
            cout << a[i];
    }
    return 0;

}



### 创建带孔洞的多边形或矩形 在 Cesium 中实现带有内部环(即孔洞)的多边形可以通过 `PolygonGeometry` 或者 `RectangleOutlineGeometry` 结合 `PolygonHierarchy` 来完成。对于复杂形状,通常推荐使用 `PolygonGeometry` 并指定多个层次结构来定义外部边界以及内部切割区域。 下面是一个利用 JavaScript 和 Cesium API 构建含孔洞多边形的例子: ```javascript // 定义外轮廓坐标数组 var outerLoop = Cesium.Cartesian3.fromDegreesArray([ -70, 40, -68, 40, -68, 38, -70, 38]); // 子路径表示内切圆(), 可以有多个这样的子路径形成不同的孔 var innerLoops = [ Cesium.Cartesian3.fromDegreesArray([-69.5, 39.5, -68.5, 39.5, -68.5, 38.5, -69.5, 38.5]) ]; // 使用 PolygonHierarchy 描述整个图形结构 var hierarchy = new Cesium.PolygonHierarchy({ positions : outerLoop, holes : [{ positions : innerLoops[0] }] }); viewer.entities.add({ polygon : { hierarchy : hierarchy, material : Cesium.Color.RED.withAlpha(0.5), outline : true, outlineColor : Cesium.Color.BLACK } }); ``` 上述代码片段展示了如何通过设置 `hierarchy` 属性中的 `holes` 字段为一个包含位置列表的对象集合来绘制具有特定开口或多处镂空效果的地图实体[^1]。 当涉及到矩形时,虽然可以直接用 `RectangleGeometry`, 若要加入孔洞,则同样需要转换成通用形式——即先构建矩形作为最外围的一圈顶点序列再按照前述方法处理即可。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值