首页 > 其他分享 >ZOJ 3935 2016

ZOJ 3935 2016

时间:2022-10-18 14:04:25浏览次数:39  
标签:include 3935 ZOJ triangular int leap year hexagonal 2016

In mathematics, a polygonal number is a number represented as dots or pebbles arranged in the shape of a regular polygon. The dots are thought of as alphas (units). These are one type of 2-dimensional figurate numbers. The following picture shows how triangular numbers, square numbers, pentagonal numbers and hexagonal numbers represented as dots arranged in the shape of corresponding regular polygon.

Polygonal Numbers: Triangular, Square, Pentagonal and Hexagonal numbers
2016 is not only a leap year but also a triangular and hexagonal year. If you are patient enough, you can count the number of the dots in the left triangle or in the right hexagon in the following picture. The number of dots in each shape is 2016.

2016 is a triangular-hexagonal-leap year
Therefore, 2016 is a triangular-hexagonal-leap year. The previous triangular-hexagonal-leap year is 1540 and the next is 2556. So living to see 2016 is very rare experience.

You task is to list the triangular-hexagonal-leap years from 2016 to 990528. 990528 is also a triangular-hexagonal-leap year.

Input

This problem has no input.

Output

Please print each triangular-hexagonal-leap year in increasing order.

For example, if you are asked to list the triangular-hexagonal-leap years from 780 to 2556, the output should be:

780
1128
1540
2016
2556
Sample Output

2016
2556
… <– some lines are skipped
990528

#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;
int a[10005];
int b[10005];
int judge(int x)
{
if(x%4==0&&x%100!=0||x%400==0)
return 1;
else
return 0;
}
int main()
{
for(int i=1;i<=10000;i++)
{

a[i]=(i*(i+1))/2;
}
for(int i=1;i<=10000;i++)
{

b[i]=i*(2*i-1);
}
int k=0;
for(int i=63;i<=10000;i++)
{
for(int j=32;j<=10000;j++)
{
if(a[i]==b[j]&&judge(a[i]))
{

printf("%d\n",a[i]);
if(a[i]==990528)
k=1;
break;
}

}
if(k)
break;
}
return 0;
}



标签:include,3935,ZOJ,triangular,int,leap,year,hexagonal,2016
From: https://blog.51cto.com/u_15834522/5766280

相关文章

  • UModel2016和EA12序列图正向和逆向工程
    UModel2016和EA12序列图正向和逆向工程一、UModel2016正向和逆向工程【步骤0】在http://www.altova.com/download-trial.html下载AltovaMissionKit2016,安装。初次运行时会......
  • [答疑精选]状态图可以表达需求吗(2016/9/18)
    状态图可以表达需求吗走单骑(37***55)15:37:20状态图是需求中出现的,是软件方法说的?潘加宇(3504847)8:45:0 只要表达的内容是"把要做的系统作为一个整体,研究其对外提供的......
  • EA画的图粘贴到其他应用时,中文就成乱码(2016/9/21)
    EA画的图粘贴到其他应用时,中文就成乱码Jeff(84***593)9:37:09请教各位:EA画的图粘贴到其他应用时,中文就成乱码了,怎么解决?Jeff(84***593)9:37:12天作岸(173**360)9:39:13先......
  • A公司(老总叫做Aer)委托我开发一个系统,请问老大是谁呢?(2016/8/24)
    A公司(老总叫做Aer)委托我开发一个系统,这个系统是为B单位某某部门(部门负责人叫Ber)开发的。请问老大是谁呢?第五元素(50***616)10:30:05请问,A公司(老总叫做Aer)委托我开发一个......
  • luogu P3685 [CERC2016]不可见的整数 Invisible Integers
    题面传送门真的吐了,写了五六个小时。首先我们不考虑两边都能走,只考虑向左走,那么的话如果两个从左到右的集合分别为\(S1,S2\),则\(S1\subsetS2\),且除去\(S1\)已经匹配掉的......
  • SQL Server 2016 自动备份
    一般策略为:Oracle:周一、二增量备份,周三差异备份,周四、五、六增量备份,周日完整备份(建多计划)MsSQL:周一、六差异备份,周日完整备份(建多计划)打开SQLserver配置管理器,设......
  • 数据集 | 以色列高中的巴格鲁特成绩(2013-2016)数据集
    下载数据集请登录爱数科该文件包含2013年至2016年之间1800多个不同学科的学校平均60,000等级的Bagrut成绩。1.字段描述2.数据预览3.字段诊断信息4.数据来源来源于Kaggle......
  • TZOJ 1693:银牛派对(最短路/dijstra)
    描述 N个农场(1≤ N ≤1000)中的每一个都有一头奶牛,编号为1.. N将参加在农场# X(1≤ X ≤ N)举行的大型奶牛聚会。总共有M (1≤ M ≤100,000)条单向(单向......
  • SQL Server 2016 安装
    数据库安装选择全新安装模式继续安装输入产品秘钥:这里使用演示秘钥进行接受许可规则检测可以后期再开放防火墙对外端口选择需要安装的功能,想省事可以选择【全选......
  • POI2016
    Nadajniki有一个妙妙树形DP。设\(f_{i,0/1/2,0/1/2,0/1/2}\)为第\(i\)个点,这个点上放没放,他儿子有没有放,他父亲有没有放。然后硬转移就行了。f[p][0][0][1]=f[p][......