当前位置:网站首页>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
- 如何判断数组中是否含有某个元素
- 19. Framebuffer application programming
- 如何展开Collapse 的所有折叠面板
- Arc135 C (the proof is not very clear)
- JS arguments parameter usage and explanation
- Understanding of cross domain and how to solve cross domain problems
- 如何获取el-tree中所有节点的父节点
- Compound nonlinear feedback control (2)
- Recommended system 1 --- framework
猜你喜欢

gslb(global server load balance)技术的一点理解

Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane

Layoutmanager layout manager: flowlayout, borderlayout, GridLayout, gridbaglayout, CardLayout, BoxLayout

JS flattened array of number shape structure

Introduction to AMBA

Uninstall Google drive hard drive - you must exit the program to uninstall

Online shrimp music will be closed in January next year. Netizens call No

卸载Google Drive 硬盘-必须退出程序才能卸载

每周小结(*63):关于正能量

509. 斐波那契数、爬楼梯所有路径、爬楼梯最小花费
随机推荐
Nexus 6p从8.0降级6.0+root
Leakage detection relay jy82-2p
Yiwen unlocks Huawei's new cloud skills - the whole process of aiot development [device access - ESP end-to-side data collection [mqtt]- real time data analysis] (step-by-step screenshot is more detai
报错cvc-complex-type.2.4.a: 发现了以元素 ‘base-extension‘ 开头的无效内容。应以 ‘{layoutlib}‘ 之一开头。
Thinkphp6.0 middleware with limited access frequency think throttle
Configure cross compilation tool chain and environment variables
2022.7.3-----leetcode. five hundred and fifty-six
Impact relay jc-7/11/dc110v
Json Web token - jwt vs. Traditional session login Authentication
[Chongqing Guangdong education] electronic circuit homework question bank of RTVU secondary school
left_and_right_net可解释性设计
如何避免 JVM 内存泄漏?
JS how to convert seconds into hours, minutes and seconds display
实用的小工具指令
JSON web token -- comparison between JWT and traditional session login authentication
fastjson
lightroom 导入图片灰色/黑色矩形 多显示器
1.1 history of Statistics
How to implement lazy loading in El select (with search function)
How to clone objects