ci/cd
continuous-integration/drone/push Build is failing Details

This commit is contained in:
clay 2022-11-03 15:38:16 +08:00
parent d9cf15ffb0
commit 25e06b13d6
2 changed files with 60 additions and 3 deletions

View File

@ -31,10 +31,17 @@ module.exports = {
// 设置侧边栏内容 // 设置侧边栏内容
sidebar: [ sidebar: [
{ {
title: '第一个侧边栏', title: '文档',
collapsable: true, collapsable: false,
children: [ children: [
'/guide/' '/wiki/',
{
title: '介绍',
collapsable: true,
children: [
'/second/introduce/'
]
}
] // 根据自己的需求来订对应自己在docs下的文件夹名默认首页是README.md ] // 根据自己的需求来订对应自己在docs下的文件夹名默认首页是README.md
}, },
{ {

View File

@ -0,0 +1,50 @@
### 1001 害死人不偿命的(3n+1)猜想 (15分)
**卡拉兹(Callatz)猜想**
对任何一个自然数n如果它是偶数那么把它砍掉一半如果它是奇数那么把(3n+1)砍掉一半。这样一直反复砍下去最后一定在某一步得到n=1。卡拉兹在1950年的世界数学家大会上公布了这个猜想传说当时耶鲁大学师生齐动员拼命想证明这个貌似很傻很天真的命题结果闹得学生们无心学业一心只证(3n+1),以至于有人说这是一个阴谋,卡拉兹是在蓄意延缓美国数学界教学与科研的进展……
我们今天的题目不是证明卡拉兹猜想而是对给定的任一不超过1000的正整数n简单地数一下需要多少步(砍几下)才能得到n=1
**输入格式**
每个测试输入包含1个测试用例即给出自然数n的值。
**输出格式**
输出从 n 计算到1需要的步数。
**输入样例**:
~~~ bash
3
~~~
**输出样例**:
~~~ bash
5
~~~
代码实现:
~~~ java
//java代码
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner =new Scanner(System.in);
int N = scanner.nextInt();
int steps =0;
while (N !=1) {
if (N %2 ==0) {
N = N /2;
} else {
N = (3 * N +1) / 2;
}
steps++;
}
System.out.println(steps);
}
}
~~~