返回题解分享
讨论 / 题解分享/ 帖子详情

蛇形填数(结果填空) - 题解

//蛇形填数2
/*
1   2   6   7   15  16  ……
3   5   8   14  17  ……
4   9   13  18  ……
10  12  19  ……
11  20  ……
21  ……
……
*/
/*
1
1  + 1 * 4 = 5
5  + 2 * 4 = 13
13 + 3 * 4 = 25
……
*/
//求第20行20列的值

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n = 20;
    int s = 1;
    for(int i = 0; i < n; i++){
        s += i * 4;
    }
    cout << s << endl;
    return 0;
}
0 回复 0 转发 0 喜欢 0 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!