博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
51NOD 1087 1 10 100 1000
阅读量:4635 次
发布时间:2019-06-09

本文共 713 字,大约阅读时间需要 2 分钟。

http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1087

暴力大法

#include
using namespace std;map
s;void solve(){ int i=1,k=1; while (i<=1e9) { s[i] = 1; i+=k; k++; }}int main (){ int t,n; solve();scanf("%d",&t); while (t--){ scanf("%d",&n); printf("%d\n",s[n]); }}

 

 

百度 an - an-1 = n-1 就可以知道通项公式

然后 用公式算

#include
using namespace std;int main (){ int t,n; scanf("%d",&t); while (t--){ scanf("%d",&n); int t = sqrt(2*n-2); if(t * (t+1) == 2*n-2) printf("1\n"); else printf("0\n"); }}

 

转载于:https://www.cnblogs.com/Draymonder/p/7365280.html

你可能感兴趣的文章
链接全局变量再说BSS段的清理
查看>>
hdu 1728 逃离迷宫
查看>>
HTML5与CSS3权威指南之CSS3学习记录
查看>>
docker安装部署
查看>>
AVL树、splay树(伸展树)和红黑树比较
查看>>
多媒体音量条显示异常跳动
查看>>
运算符及题目(2017.1.8)
查看>>
React接入Sentry.js
查看>>
ssh自动分发密匙脚本样板
查看>>
转 小辉_Ray CORS(跨域资源共享)
查看>>
Linux安装postgresql
查看>>
MyBatis启动:MapperStatement创建
查看>>
Tomcat 调优及 JVM 参数优化
查看>>
【kindeditor】KindEditor获取多个textarea文本框的值并判断非空
查看>>
【 全干货 】5 分钟带你看懂 Docker !
查看>>
[转]优化Flash性能
查看>>
【大话设计模式】——浅谈设计模式基础
查看>>
popStar手机游戏机机对战程序
查看>>
hadoop2.4.1集群搭建
查看>>
Android采用Application总结一下
查看>>