当前位置:网站首页>Number of briquettes & Birthday Candles & building blocks
Number of briquettes & Birthday Candles & building blocks
2022-07-26 08:30:00 【StephenYYYou】
Number of coal balls
2016 The difficulty of the year title is obviously higher than 2017 It's much simpler in .
package lanqiao.lanqiao_2016;
/**
* Created by ministrong on 2020/3/4.
*
*
Number of coal balls
There's a bunch of coal balls , Pile up in a triangular pyramid . Specifically :
On the first floor 1 individual ,
The second floor 3 individual ( In a triangle ),
The third level 6 individual ( In a triangle ),
The fourth level 10 individual ( In a triangle ),
....
If there is 100 layer , How many coal balls are there ?
Please fill in the number of coal balls .
Be careful : You should submit an integer , Don't fill in any extra content or explanatory text .
answer :171700
*/
public class Q1_2016_7_meiqiu {
public static void main(String[] args) {
int res=0;// in total
int t=0;// Each layer
for(int i=1;i<101;i++){
t=t+i;
res+=t;
}
System.out.println(res);
}
}
birthday candle
package lanqiao.lanqiao_2016;
/**
* Created by ministrong on 2020/3/4.
*
*
birthday candle
From a certain year on, you hold a birthday every year party, And blow out the same number of candles with the same age every time .
Now count , He blew it out altogether 236 A candle .
Excuse me, , How old was his birthday party Of ?
Please fill in his birthday party The age of .
Be careful : You should submit an integer , Don't fill in any extra content or explanatory text .
answer :26
*/
public class Q2_2016_7_shengri {
public static void main(String[] args) {
for(int i=1;i<200;i++){
int res=0;
for(int j=i;j<200;j++){
res+=j;
if(res==236) System.out.println(i);
}
}
}
}
Building blocks
package lanqiao.lanqiao_2016;
/**
* Created by ministrong on 2020/3/4.
*
Building blocks
Xiao Ming likes to build digital blocks recently ,
Altogether 10 A building block , There's a number on each block ,0~9.
Building block rules :
Each block is placed on top of the other two blocks , And it must be smaller than the two building block numbers below .
Finally, it was built into 4 The pyramid of layers , All the building blocks have to be used up .
Here are two qualified methods :
0
1 2
3 4 5
6 7 8 9
0
3 1
7 5 2
9 8 6 4
Please calculate the total number of such methods ?
Please fill in the number indicating the total number .
Be careful : You should submit an integer , Don't fill in any extra content or explanatory text .
answer :768
*/
import java.lang.reflect.Array;
import java.util.Arrays;
/***
* Yes 1~9 Full Permutation , requirement ,a[0]<a[2] and a[3],a[1]<a[3] and a[4],a[2]<a[5] and a[6],a[3]<a[6] and a[7],a[4]<a[7] and a[8]
*/
public class Q3_2016_7_jimu {
public static int[] a=new int[]{1,2,3,4,5,6,7,8,9};
public static void main(String[] args) {
int res=0;
do{
if(isok(a)) res++;
}while(nextque());
System.out.println(res);
}
public static boolean isok(int[] a){
return a[0]<a[2] && a[0]<a[3] && a[1]<a[3] && a[1]<a[4] && a[2]<a[5] && a[2]<a[6] && a[3]<a[6] && a[3]<a[7] && a[4]<a[7] && a[4]<a[8];
}
public static boolean nextque(){
int x=-1;
for(int i=8;i>0;i--){
if(a[i]>a[i-1]){
x=i-1;
break;
}
}
if(x==-1) return false;
int y=-1;
for(int i=8;i>x;i--){
if(a[i]>a[x]){
y=i;
break;
}
}
int t=a[x];
a[x]=a[y];
a[y]=t;
Arrays.sort(a,x+1,a.length);
return true;
}
}
Lexicographic order for complete arrangement : With a[5]={35876} For example
1. Find the first decreasing adjacent number from right to left , Write down the subscript of the number on the left i: here 58 First decline , Record 5 The subscript of is i=1.
2. Find the first one from right to left a[i] Big numbers , Record its subscript j: here 6 It's the first one 5 Big , Record 6 The subscript j=4.
3. In exchange for a[i] and a[j] The number of , The sequence becomes :36875.
4. Then subscript i The following sequence is arranged from small to large , Get the results :36578.
ps: If the decreasing adjacent number is not found in the first step , It means that this arrangement is the last one .
边栏推荐
- Flutter compilation fails
- Flutter WebView jitter
- Flutter upgrade 2.10
- Common Oracle functions
- 23.2 customizing the banner control display hidden banner modify banner
- Kotlin program control
- 【EndNote】文献模板编排语法详解
- Flitter imitates wechat long press pop-up copy recall paste collection and other custom customization
- Basic music theory rhythm connection problem, very important
- Vscode domestic image server acceleration
猜你喜欢

Bee guitar score high octave and low octave

Kotlin program control

mysql函数汇总之日期和时间函数

2022-7-6 personal qualifying 3 competition experience

全网最全:Mysql六种约束详解

QT note 1

22-07-12 personal training match 1 competition experience

【C语言】程序员筑基功法——《函数栈帧的创建与销毁》

2022-7-7 personal qualifying 4 competition experience

22-07-14 personal training match 2 competition experience
随机推荐
2022-7-8 personal qualifying 5 competition experience (supplementary)
awk作业
vscode 实用快捷键
关于期刊论文所涉及的一些概念汇编+期刊查询方法
Grid segmentation
B title: razlika priority queue approach
Daily Note (11) -- word formula input arbitrary matrix
Sed job
为什么要在时钟输出上预留电容的工位?
第三天作业
Please tell me if there is any way to increase the write out rate when the Flink SQL client is in the sink table. When synchronizing through sink table
Prefix infix suffix expression (written conversion)
Use of room database in kotlin
Beauty naked chat for a while, naked chat over the crematorium!
Basic music theory rhythm connection problem, very important
Share high voltage ultra low noise LDO test results
23.2 customizing the banner control display hidden banner modify banner
Apple's tough new rule: third-party payment also requires a percentage, and developers lose a lot!
Why reserve a capacitor station on the clock output?
【时间复杂度空间复杂度】