当前位置:网站首页>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 .
边栏推荐
- Kotlin operator
- Mycat2 sub database and sub table
- Recurrence of strtus2 historical vulnerability
- A summary of practical websites that won't brighten people's eyes
- import error: ‘Icon‘ is not exported from ‘antd‘. Import icon error
- Nodejs2day(nodejs的模块化,npm下载包,模块加载机制)
- Regular expression job
- 23.10 Admin features
- 23.8 using the applicationrunner or commandlinerunner to implement applicationrunner and commandlinerunner
- Flutter WebView jitter
猜你喜欢

Burp suite Chapter 9 how to use burp repeater

Let's talk about the three core issues of concurrent programming.

Mycat2 deploy master-slave MariaDB

Kotlin operator

Take out brother is the biggest support in this society

Matplotlib learning notes

2022-7-7 personal qualifying 4 competition experience

Daily Note (11) -- word formula input arbitrary matrix

苹果强硬新规:用第三方支付也要抽成,开发者亏大了!

【C语言】程序员筑基功法——《函数栈帧的创建与销毁》
随机推荐
OSPF summary
Seq2seq and attention model learning notes
I am 35 years old.
Basic music theory rhythm connection problem, very important
Lesson 3: gcc compiler
Sed job
vim跨行匹配搜索
Recurrence of strtus2 historical vulnerability
Flutter custom player progress bar
Uninstallation of dual systems
2022 / 7 / 16 exam summary
22-07-16 personal training match 3 competition experience
Day 3 homework
Does flinkcdc now support sqlserver instance name connection?
Problems caused by slivereappbar
Kotlin program control
2022-024ARTS:最长有效括号
Share high voltage ultra low noise LDO test results
B title: razlika priority queue approach
Matplotlib learning notes