当前位置:网站首页>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;
}边栏推荐
- Review | categories and mechanisms of action of covid-19 neutralizing antibodies and small molecule drugs
- tutle时钟改进版
- 【无标题】
- BUU-Pwn-test_ your_ nc
- fastjson
- Input displays the currently selected picture
- 1480. Dynamic sum of one-dimensional array
- AWT常用组件、FileDialog文件选择框
- Overview of relevant subclasses of beanfactorypostprocessor and beanpostprocessor
- JSON web token -- comparison between JWT and traditional session login authentication
猜你喜欢

Actual cases and optimization solutions of cloud native architecture

509. Fibonacci number, all paths of climbing stairs, minimum cost of climbing stairs

AWT介绍

Programmers don't talk about morality, and use multithreading for Heisi's girlfriend

Sword finger offer II 038 Daily temperature

High performance parallel programming and optimization | lesson 02 homework at home

Steady! Huawei micro certification Huawei cloud computing service practice is stable!
![BUU-Crypto-[GUET-CTF2019]BabyRSA](/img/87/157066155e8d3a93e30a68eaf1781b.jpg)
BUU-Crypto-[GUET-CTF2019]BabyRSA

Grounding relay dd-1/60

AWT common components, FileDialog file selection box
随机推荐
Recommended system 1 --- framework
C language exercises (recursion)
HMS v1.0 appointment.php editid参数 SQL注入漏洞(CVE-2022-25491)
配置交叉编译工具链和环境变量
Review | categories and mechanisms of action of covid-19 neutralizing antibodies and small molecule drugs
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
注释与注解
509. Fibonacci number, all paths of climbing stairs, minimum cost of climbing stairs
Steady! Huawei micro certification Huawei cloud computing service practice is stable!
How to choose the middle-aged crisis of the testing post? Stick to it or find another way out? See below
Invalid revision: 3.18.1-g262b901-dirty
QT releases multilingual International Translation
JSON Web Token----JWT和傳統session登錄認證對比
BUU-Crypto-Cipher
如何避免 JVM 内存泄漏?
Programmers don't talk about morality, and use multithreading for Heisi's girlfriend
BUU-Pwn-test_ your_ nc
How to get the parent node of all nodes in El tree
ES6 modularization
Input displays the currently selected picture