当前位置:网站首页>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;
}边栏推荐
- Configure cross compilation tool chain and environment variables
- SQL injection - injection based on MSSQL (SQL Server)
- Leakage detection relay jy82-2p
- Kubernets first meeting
- JSON Web Token----JWT和传统session登录认证对比
- webrtc 快速搭建 视频通话 视频会议
- Component、Container容器常用API详解:Frame、Panel、ScrollPane
- 检漏继电器JY82-2P
- left_ and_ right_ Net normal version
- AWT常用组件、FileDialog文件选择框
猜你喜欢

Canoe panel learning video

报错cvc-complex-type.2.4.a: 发现了以元素 ‘base-extension‘ 开头的无效内容。应以 ‘{layoutlib}‘ 之一开头。

js如何将秒转换成时分秒显示

How much computing power does transformer have

509. Fibonacci number, all paths of climbing stairs, minimum cost of climbing stairs
![[microservice] Nacos cluster building and loading file configuration](/img/50/7af220c57a06eb186729c9882d9dab.png)
[microservice] Nacos cluster building and loading file configuration

我的NVIDIA开发者之旅——优化显卡性能

Configure cross compilation tool chain and environment variables

win10清除快速访问-不留下痕迹

Halcon图片标定,使得后续图片处理过后变成与模板图片一样
随机推荐
Detectron: train your own data set -- convert your own data format to coco format
input显示当前选择的图片
js如何将秒转换成时分秒显示
接地继电器DD-1/60
19. Framebuffer application programming
如何判断数组中是否含有某个元素
卸载Google Drive 硬盘-必须退出程序才能卸载
Nexus 6p downgraded from 8.0 to 6.0+root
left_ and_ right_ Net normal version
Upper computer software development - log information is stored in the database based on log4net
left_and_right_net可解释性设计
Lightroom import picture gray / Black rectangular multi display
Leakage detection relay jy82-2p
FRP intranet penetration, reverse proxy
Sword finger offer II 038 Daily temperature
Google Chrome browser will support the function of selecting text translation
The difference between PX EM rem
QT 获取随机颜色值设置label背景色 代码
fastjson
509. Fibonacci number, all paths of climbing stairs, minimum cost of climbing stairs