April Fools Day Contest 2019: editorial回顾补题

本文介绍了一种名为ThanosSort的趣味排序算法及其实现方式,并通过示例详细解释了如何使用该算法获得最长有序子数组。此外,还介绍了KanbanNumbers问题的解决方法,即如何判断一个数在英文表示中是否包含特定字母。
A. Thanos Sort
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Thanos sort is a supervillain sorting algorithm, which works as follows: if the array is not sorted,

snap your fingers* to remove the first or the second half of the items, and repeat the process.

Given an input array, what is the size of the longest sorted array you can obtain from it using Thanos sort?

*Infinity Gauntlet required.

Input

The first line of input contains a single number nn (1n161≤n≤16) — the size of the array. nn is guaranteed to be a power of 2.

The second line of input contains nn space-separated integers aiai (1ai1001≤ai≤100) — the elements of the array.

Output

Return the maximal length of a sorted array you can obtain using Thanos sort

. The elements of the array have to be sorted in non-decreasing order.

Examples
input
Copy
4
1 2 2 4
output
Copy
4
input
Copy
8
11 12 1 2 13 14 3 4
output
Copy
2
input
Copy
4
7 6 5 4
output
Copy
1
Note

In the first example the array is already sorted, so no finger snaps are required.

In the second example the array actually has a subarray of 4 sorted elements, but you can not remove elements

from different sides of the array in one finger snap. Each time you have to remove either the whole first half or th

whole second half, so you'll have to snap your fingers twice to get to a 2-element sorted array.

In the third example the array is sorted in decreasing order, so you can only save one element from the ultimate destruction.

思路:可以用递归先判断是不是排好了,如果没有,那么再看前半段或者后半段

返回最大值即可

#include<iostream>
using namespace std;
int a[100];
int b[17],c[17],d[17];
int ff(int x,int y){
    int t=1,sum=1;
    for(int i=x+1;i<=y;i++){
            if(a[i]>=a[i-1])
            sum++;
        else{
            t=0;
        }
    }
    if(t==1)
    return sum;
    else
    return max(ff(x,(x+y-1)/2),ff((x+y+1)/2,y));
}
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    cout<<ff(1,n)<<endl;
    return 0;
}
B. Kanban Numbers
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
 
Input

The input contains a single integer aa (1a991≤a≤99).

Output

Output "YES" or "NO".

Examples
input
 
5
output
 
YES
input
 
13
output
 
NO
input
 
24
output
 
NO
input
 
46
output
 
YES
这个就是脑洞题了,题目信息很少,kanban数就是把数字转化为英语,
然后含有k,n,a,b的为no
没有这些字母的是yes;真是脑洞大开
C. Mystery Circuit
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Input

The input contains a single integer aa (0a150≤a≤15).

Output

Output a single integer.

Example
input
 
3
output
 
13
 
    

转载于:https://www.cnblogs.com/yfr2zaz/p/10646145.html

### 关于2025年愚人节技术笑话或IT相关事件的信息 目前关于具体日期如2025年的愚人节(April Fools' Day 2025)上的科技笑话或IT相关活动尚未有确切记录。然而,可以推测的是,在这一天可能会延续以往的传统,各大科技公司和媒体会发布一些具有创意和技术背景的恶作剧内容[^1]。 通常情况下,每年的愚人节期间,许多知名的技术企业都会利用这一机会推出虚构的产品或者服务来娱乐公众。例如谷歌曾宣布过不存在的功能如“Google Nose”用于嗅觉搜索;又比如特斯拉可能开玩笑说他们开发了一款可以在火星上种植植物的家庭设备等等。这些玩笑往往基于当前快速发展的科学技术趋势之上,并结合幽默感吸引人们的注意[^2]。 尽管现在还没有针对2025年具体的计划被公开披露出来,但随着人工智能、量子计以及其他前沿领域研究不断取得进展,未来几年里我们可以期待更加复杂且令人惊叹的 April Fools’ pranks from tech giants. 对于个人而言,也可以尝试自己动手制作简单的程序作为朋友间的玩笑材料。下面提供了一个简单Python脚本例子,它假装能够预测用户的幸运号码: ```python import random def get_lucky_number(name): lucky_number = random.randint(1, 100) return f"{name}, your predicted lucky number is {lucky_number}!" print(get_lucky_number(input("Enter your name to predict your lucky number: "))) ``` 此代码接受输入的名字并随机生成一个介于1到100之间的整数作为所谓的“幸运号”。虽然这只是个小把戏,但在特定场合下却能增添不少乐趣。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值