意甲冠军:1,3是完美的数,假定a,b是完美的数,然后,2+a*b+2*a+2*b,结论认为,n无论是完美的数字。

解法:開始仅仅看出来2+a*b+2*a+2*b=(a+2)*(b+2)-2,没推出很多其它结论,囧。没办法,仅仅能暴力将全部的完美数求出来然后查表。正解是c+2=(a+2)*(b+2);完美数都是有质因子3或5组成的(5本身除外);

自己暴力代码:

/******************************************************
* author:xiefubao
*******************************************************/
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <string.h>
//freopen ("in.txt" , "r" , stdin);
using namespace std; #define eps 1e-8
#define zero(_) (abs(_)<=eps)
const double pi=acos(-1.0);
typedef long long LL;
const int Max=1010;
const int INF=1000000000; LL num[Max];
int help[Max];
LL get(int l,int r)
{
return 2*(num[l]+1)*(num[r]+1)-num[l]*num[r];
}
struct point
{
LL ans;
int h;
};
bool operator<(const point& a,const point& b)
{
return a.ans>b.ans;
}
priority_queue<point> pri;
int main()
{
num[0]=1;
num[1]=3;
point p;
p.ans=7;
p.h=0;
pri.push(p);
p.ans=23;
p.h=1;
pri.push(p);
for(int i=0; i<Max; i++)
help[i]=i;
help[0]=1;
help[1]=2;
int po=2;
while(pri.top().ans<=INF)
{
point ptop=pri.top();
pri.pop();
if(num[po-1]==ptop.ans)
{
point p;
p.ans=get(ptop.h,help[ptop.h]);
p.h=ptop.h;
pri.push(p);
help[ptop.h]++;
continue;
}
point p;
p.ans=get(ptop.h,help[ptop.h]);
p.h=ptop.h;
pri.push(p);
help[ptop.h]++;
// cout<<ptop.ans<<" ";
num[po++]=ptop.ans; p.ans=get(po-1,po-1);
p.h=po-1;
pri.push(p);
help[po-1]=po;
}
int t;
while(scanf("%d",&t)==1)
{
if(binary_search(num,num+po,t))
puts("Yes");
else
puts("No");
}
return 0;
}

版权声明:本文博主原创文章,博客,未经同意不得转载。

Acdreamoj1115(数学思维称号)的更多相关文章

  1. 程序设计中的数学思维函数总结(代码以C#为例)

    最近以C#为例,学习了程序设计基础,其中涉及到一些数学思维,我们可以巧妙的将这些逻辑问题转换为代码,交给计算机运算. 现将经常会使用到的基础函数做一总结,供大家分享.自己备用. 1.判断一个数是否为奇 ...

  2. PJ考试可能会用到的数学思维题选讲-自学教程-自学笔记

    PJ考试可能会用到的数学思维题选讲 by Pleiades_Antares 是学弟学妹的讲义--然后一部分题目是我弄的一部分来源于洛谷用户@ 普及组的一些数学思维题,所以可能有点菜咯别怪我 OI中的数 ...

  3. UVa10025 The ? 1 ? 2 ? ... ? n = k problem 数学思维+规律

    UVa10025 ? 1 ? 2 ? ... ? n = k problem The problem Given the following formula, one can set operator ...

  4. B. Tell Your World(几何数学 + 思维)

    B. Tell Your World time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  5. hdu 4710 Balls Rearrangement (数学思维)

    意甲冠军:那是,  从数0-n小球进入相应的i%a箱号.然后买一个新的盒子. 今天的总合伙人b一个盒子,Bob试图把球i%b箱号. 求复位的最小成本. 每次移动的花费为y - x ,即移动前后盒子编号 ...

  6. F. Multicolored Markers(数学思维)

    思维:思维就是将大的矩形放在小矩形里面,让大矩形的宽和长尽量靠近. 很容易得到 (a+b)% i = 0 的话, 保证了大矩形的形成,同时里面表示了两种情况:1, a % i =0, b % i=0; ...

  7. Pythagorean Triples毕达哥斯拉三角(数学思维+构造)

    Description Katya studies in a fifth grade. Recently her class studied right triangles and the Pytha ...

  8. HDU - 6409:没有兄弟的舞会(数学+思维)

    链接:HDU - 6409:没有兄弟的舞会 题意: 题解: 求出最大的 l[i] 的最大值 L 和 r[i] 的最大值 R,那么 h 一定在 [L, R] 中.枚举每一个最大值,那么每一个区间的对于答 ...

  9. Wannafly交流赛1 B 硬币[数学思维/贪心]

    链接:https://www.nowcoder.com/acm/contest/69/B来源:牛客网 蜥蜴的生日快到了,就在这个月底! 今年,蜥蜴的快乐伙伴之一壁虎想要送好多个1元硬币来恶整蜥蜴. 壁 ...

随机推荐

  1. thinkPHP 模板的使用技巧(十三)

    原文:thinkPHP 模板的使用技巧(十三) 模板的使用技巧:页面跳转 .模板包含.模板渲染.模板的继承 页面跳转 <a href='__URL__/index'>我要跳转到首页面,用这 ...

  2. ACM-计算几何之Quoit Design——hdu1007 zoj2107

    Quoit Design Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  3. 设计模式之——Factory(工厂模式)

    工厂模式用于,通过统一的创建对象接口来创建对象,而子类可以决定对象的创建方式. class CObject { }; class CCar : public CObject { }; class CF ...

  4. C语言中的system函数參数具体解释

    http://blog.csdn.net/pipisorry/article/details/33024727 函数名: system 功   能: 发出一个DOS命令   用   法: int sy ...

  5. 【C语言】写一个函数,实现字符串内单词逆序

    //写一个函数,实现字符串内单词逆序 //比如student a am i.逆序后i am a student. #include <stdio.h> #include <strin ...

  6. loj1341(数学)

    传送门:Aladdin and the Flying Carpet 题意: 给出两个正整数1<=m<=n<=1e12.问N可以拆成多少对p*q,使得p和q中最小的不小于a,且p!=q ...

  7. Android_app项目开发步骤总结

    做了几个android企业应用项目后,总结了项目的基本开发步骤.希望可以交流. 一 应用规划:      ※确定功能.      ※必须的界面及界面跳转的流程.      ※须要的数据及数据的来源及格 ...

  8. UVa 1292 - Strategic game (树形dp)

    本文出自   http://blog.csdn.net/shuangde800 题目链接: 点击打开链接 题目大意 给定一棵树,选择尽量少的节点,使得每个没有选中的结点至少和一个已选结点相邻. 思路 ...

  9. Struts2 学习第一步准备工作

    第一步:安装下载MyEclispe10 对于MyEclispe的下载安装就不再详述了. 第二步:下载Struts-2.3.15 Struts-2.3.15下载地址: http://struts.apa ...

  10. 从后台绑定数据到ligerui 的comboBox下拉框组件

    这次来记录一下ligerUI的comboBox下拉框组件,ligerUI的API里也有相关描写叙述,上面都是前台写死数据,然后显示在组件中,我这次要说的是将后台的数据绑定到下拉框组件中,废话不多说. ...