当前位置:网站首页>C language - Blue Bridge Cup - Snake filling
C language - Blue Bridge Cup - Snake filling
2022-07-04 06:01:00 【@Xiaoyu~】
Title Description
As shown in the figure below , Xiao Ming uses from 1 A positive integer at the beginning “ Serpentine ” Fill an infinite matrix .
1 2 6 7 15 …
3 5 8 14 …
4 9 13 …
10 12 …
11 …
…
It is easy to see that the number in the second row and second column of the matrix is 5. Please calculate the number... In the matrix 20 Xing di 20 Column
What's the number of ?
1. Solution 1
The observation position is (1,1),(2,2),(3,3)(4,4)~~ The number of ,
It can be found that they are 1,5,13, 25~~, Find the law of these numbers and add 4* Subscript of the number , Such as :5=1+4*1;13=5+4*2;25=13+4*3~~, From this, we can design a function to solve
2. Method 2
Rotate the matrix clockwise 45°, Then look for rules . You can find that the twentieth row and the twentieth column are the middle of the thirty ninth row after rotation , Then we can find the order of odd behavior by observing , Even number behavior in reverse order , Then there are several numbers in the first few lines , From this, we can find the last number in line 39 , subtracting (39-1) Half of , That is, the number in the middle of the thirty-nine lines
3. The answer for 761
4. The attached code is as follows
1.
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
int i = 0;
int a = 1;
for (i = 1; i <= 19; i++)
{
a = a + i * 4;
}
printf("%d\n", a);
return 0;
}
2.
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
int i = 0;
int a = 0;
int b = 0;
a = 20 * 2 - 1;
for (i = 1; i <= a; i++)
{
b += i;
}
b = b - (a - 1) / 2;
printf("%d\n", b);
return 0;
}
边栏推荐
- How to clone objects
- 检漏继电器JY82-2P
- 配置交叉编译工具链和环境变量
- 2022.7.2-----leetcode. eight hundred and seventy-one
- How to implement lazy loading in El select (with search function)
- transformer坑了多少算力
- 19. Framebuffer application programming
- Practical gadget instructions
- SQL injection - injection based on MSSQL (SQL Server)
- How to expand all collapse panels
猜你喜欢
(4) Canal multi instance use
Notes and notes
BUU-Pwn-test_ your_ nc
Kubernets first meeting
一键过滤选择百度网盘文件
How does apscheduler set tasks not to be concurrent (that is, execute the next task after the first one)?
Component、Container容器常用API详解:Frame、Panel、ScrollPane
复合非线性反馈控制(二)
Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane
Tf/pytorch/cafe-cv/nlp/ audio - practical demonstration of full ecosystem CPU deployment - Intel openvino tool suite course summary (Part 2)
随机推荐
(4) Canal multi instance use
Understanding of cross domain and how to solve cross domain problems
Install pytoch geometric
Kubernets first meeting
BUU-Crypto-[GXYCTF2019]CheckIn
Win10 clear quick access - leave no trace
Json Web token - jwt vs. Traditional session login Authentication
Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane
How to choose the middle-aged crisis of the testing post? Stick to it or find another way out? See below
剑指 Offer II 038. 每日温度
Grounding relay dd-1/60
Arc135 a (time complexity analysis)
MySQL的information_schema数据库
Practical gadget instructions
One click filtering to select Baidu online disk files
如何实现视频平台会员多账号登录
LC weekly 300
JS execution mechanism
Configure cross compilation tool chain and environment variables
Impact relay jc-7/11/dc110v