Problem 28 Number spiral diagonals (规律题)
来源:互联网 发布:淘宝客服工作内容 编辑:程序博客网 时间:2024/06/05 07:00
Number spiral diagonals
Problem 28
Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:
21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 15 14 13
It can be verified that the sum of the numbers on the diagonals is 101.
What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed in the same way?
题解:规律题....
代码:
#include<bits/stdc++.h>using namespace std;int main(){long long ans=1;int count=0;int k=2;for(int i=3;i<=1001*1001;i+=k){//cout<<i<<endl;ans+=i;count++;if(count==4){k+=2;count=0;}}cout<<ans<<endl;return 0;}
1 0
- Problem 28 Number spiral diagonals (规律题)
- (Problem 28)Number spiral diagonals
- projecteuler---->problem=28----Number spiral diagonals
- Project Euler:Problem 28 Number spiral diagonals
- PE 28 Number spiral diagonals
- 欧拉工程第28题:Number spiral diagonals
- 28 Number spiral diagonals - Project Euler +
- No_28:Number spiral diagonals
- Number spiral diagonals
- URAL 1224. Spiral (规律)
- ZOJ 3798 Abs Problem(规律题)
- hdoj--1005--Number Sequence(规律题)
- Number Sequence(规律)
- Problem A. Number Theory Problem(2016China-Final)【找规律】
- number number number (数字规律)
- 1694. Spiral (找规律)
- HDU1005 Number Sequence(规律题)
- HDU 4279 Number 规律题
- 图片搜索算法
- Win7 64位系统上配置使用32位的Eclipse
- Web开发之Mode2MVC(jap+servlet+javaBean)设计模式
- LeetCode No.16 3Sum Closest
- 没那么难,谈CSS的设计模式
- Problem 28 Number spiral diagonals (规律题)
- 参考文献检索技巧(ACM检索库)
- JS实现网络拓扑图
- Javascript闭包——懂不懂由你,反正我是懂了
- Github 在ubuntu下的配置
- 为什么说DOM操作很慢
- Docker使用Link在容器之间建立连接
- 前端必读:浏览器内部工作原理
- 程序员应该关注的一些事儿