51NOD 1087 1 10 100 1000
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1087
暴力大法
#include<bits/stdc++.h>
using namespace std;
map <int,int>s; void solve()
{
int i=,k=;
while (i<=1e9)
{
s[i] = ;
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<bits/stdc++.h>
using namespace std; int main ()
{
int t,n;
scanf("%d",&t);
while (t--){
scanf("%d",&n);
int t = sqrt(*n-);
if(t * (t+) == *n-)
printf("1\n");
else
printf("0\n");
}
}
51NOD 1087 1 10 100 1000的更多相关文章
- 51nod 1087 1 10 100 1000【打表】
题目来源: Ural 1209 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 收藏 关注 1,10,100,1000...组成序列1101001000...,求 ...
- 51Nod 1087 1 10 100 1000 | 数学
Input示例 3 1 2 3 Output示例 1 1 0 #include "bits/stdc++.h" using namespace std; #define LL lo ...
- 1087 1 10 100 1000(打表 set 数学)
1087 1 10 100 1000 题目来源: Ural 1209 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 收藏 关注 1,10,100,1000... ...
- Ural 1209. 1, 10, 100, 1000... 一道有趣的题
1209. 1, 10, 100, 1000... Time limit: 1.0 secondMemory limit: 64 MB Let's consider an infinite seque ...
- Timus - 1209 - 1, 10, 100, 1000...
先上题目: 1209. 1, 10, 100, 1000... Time limit: 1.0 secondMemory limit: 64 MB Let's consider an infinite ...
- [51NOD1087]1 10 100 1000(规律,二分)
题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1087 用高中的数列知识就可以推出公式,不难发现f(n)=f(n ...
- 背水一战 Windows 10 (100) - 应用间通信: 分享
[源码下载] 背水一战 Windows 10 (100) - 应用间通信: 分享 作者:webabcd 介绍背水一战 Windows 10 之 应用间通信 分享 示例1.本例用于演示如何开发一个分享的 ...
- 用js实现随机选取10–100之间的10个数字,存入一个数组,并排序
var iArray = []; function getRandom(istart, iend) { var iChoice = iend - istart + 1; //加1是为了取到100 va ...
- ResourceWarning: unclosed <socket.socket fd=864, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('10.100.x.x', 37321), raddr=('10.1.x.x', 8500)>解决办法
将代码封装,并使用unittest调用时,返回如下警告: C:\python3.6\lib\collections\__init__.py:431: ResourceWarning: unclosed ...
随机推荐
- requests的post请求:百度翻译
import json import requests class Trans(object): def __init__(self, juzi): self.juzi = juzi self.bas ...
- requests爬取百度贴吧:python 美女 3
import requests import sys class Tieba(object): def __init__(self, tieba_name, pn): self.tieba_name ...
- 010-mac下常用命令
1.查看某个端口是否运行 lsof -i tcp:port lsof -i:8080 2.强制关闭进程 kill -9 PID
- python中计算程序用时的方法
import time start = time.clock() ...... end = time.clock() print(end - start)
- Jquery each&forEach
jQuery方法 语法 .each() 作用 用来遍历dom 用法 $(dom).each( function(index, Element) ) { do Something... } 参数 第一个 ...
- CentOS7更改Docker默认镜像和容器存储位置
图片出处:https://bobcares.com/wp-content/uploads/docker-change-directory.jpg 一.Why? 通常,当你开始使用docker时,我们并 ...
- 课堂练习Complex类
Complex类 #include<iostream> #include<cmath> using namespace std; class Complex { public: ...
- sql2008评估板过期
1.查看sql2008到期时间,打开数据库---帮助---关于,具体可查看试用期还有多长时间 2.重新激活 : ① 打开注册表后,找到并把 HKEY_LOCAL_MACHINE\SOFTWARE\Mi ...
- matplotlib显示中文
[注意] 可能与本文主题无关,不过我还是想指出来:使用matplotlib库时,下面两种导入方式是等价的(我指的是等效,当然这个说法可以商榷:) import matplotlib.pyplot as ...
- [转]autoid文件上传
原文地址:https://www.cnblogs.com/yoyoketang/p/7612026.html 前言 关于非input文件上传,点上传按钮后,这个弹出的windows的控件了,已经跳出三 ...