zoj3768Continuous Login
这题通过暴力可以看出最多不超过3 具体为什么。。等着看大牛的题解。
可以预处理出来两个数之和 用bool存下 然后枚举一个数 二分剩余数的位置就可以了 勉强可过
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 123456789
#define M 16000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
bool f[N];
int g;
vector<int>a;
vector<int>::iterator it;
void init()
{
int i,j;
for(i = ;; i++)
{
int k = (i)*(i+)/;
if(k<=N)
{
a.push_back(k);
}
else break;
}
g = i;
for(i = ; i < g ;i++)
for(j = i; j < g ; j++)
{
int s = a[i]+a[j];
if(s>N) break;
f[s] = ;
}
}
int main()
{
int i,n,m;
init();
cin>>m;
while(m--)
{
cin>>n;
it = lower_bound(a.begin(),a.end(),n);
if((*it)==n)
{
printf("%d\n",it+-a.begin());
continue;
}
if(f[n])
{
for(i = ;i < g ; i++)
{
int k = n-a[i];
if(k<=) break;
it = lower_bound(a.begin(),a.end(),k);
if((*it)==k)
{
printf("%d %d\n",i+,it+-a.begin());
break;
}
}
}
else
{
int k;
for(i = ; i < g ;i++)
{
k = n-a[i];
if(f[k])
{
printf("%d ",i+);
break;
}
}
for(i = ;i < g ;i++)
{
int kk = k-a[i];
it = lower_bound(a.begin(),a.end(),kk);
if((*it)==kk)
{
printf("%d %d\n",i+,it+-a.begin());
break;
}
}
}
}
return ;
}
zoj3768Continuous Login的更多相关文章
- 浅谈SQL注入风险 - 一个Login拿下Server
前两天,带着学生们学习了简单的ASP.NET MVC,通过ADO.NET方式连接数据库,实现增删改查. 可能有一部分学生提前预习过,在我写登录SQL的时候,他们鄙视我说:“老师你这SQL有注入,随便都 ...
- 打开程序总是会提示“Enter password to unlock your login keyring” ,如何成功关掉?
p { margin-bottom: 0.1in; line-height: 120% } 一.一开始我是按照网友所说的 : rm -f ~/.gnome2/keyrings/login.keyrin ...
- Day01 login module
知识点:模块导入 变量赋值的两种形式 格式化输出 for循环 if...else 嵌套 #!C:\Program Files\Python35/bin # -*- conding:utf-8 ...
- Login控件尝试
新建web项目,添加default.aspx.Register.aspx.Login.aspx. default.aspx中添加LoginName.LoginStatus,LoginName的Form ...
- [转载] 构造linux 系统下免密码ssh登陆 _How to establish password-less login with SSH
In present (post production) IT infrastructure many different workstations, servers etc. have to be ...
- Security9:查询Login被授予的权限
在给一个Login授予权限时,发现该Login已经存在,其对应的User也存在于指定的DB中,查看该Login在指定DB中已被授予的权限. 1,查看Login的Server PrincipalID s ...
- php中的登陆login
Login <?php require "../include/DBClass.php"; $username=$_POST['UserName']; $password=$ ...
- MS SQL Could not obtain information about Windows NT group/user 'domain\login', error code 0x5. [SQLSTATE 42000] (Error 15404)
最近碰到一个有趣的错误:海外的一台数据库服务器上某些作业偶尔会报错,报错信息如下所示: -------------------------------------------------------- ...
- MS SQL错误:SQL Server failed with error code 0xc0000000 to spawn a thread to process a new login or connection. Check the SQL Server error log and the Windows event logs for information about possible related problems
早晨宁波那边的IT人员打电话告知数据库无法访问了.其实我在早晨也发现Ignite监控下的宁波的数据库服务器出现了异常,但是当时正在检查查看其它服务器发过来的各类邮件,还没等到我去确认具体情 ...
随机推荐
- Ehcache CacheManager
CacheManager是Ehcache框架的核心类和入口,它负责管理一个或多个Cache对象.要使用Ehcache框架,必须要先创建 CacheManager 对象.现在我们学习下,如何创建 Cac ...
- Handler有何作用?怎样使用?
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u012974916/article/details/24580405 一 Handler作用和概念 ...
- C++11 std::function、std::bind和lambda表达式
参考博客: C++可调用对象详解-https://www.cnblogs.com/Philip-Tell-Truth/p/5814213.html 一.关于std::function与std::bin ...
- #import @import #include
1.在xcode5以后 ,Replace #import <Cocoa/Cocoa.h> with @import Cocoa; 在这之前 必须手动设置一下才能用. 2.#import 与 ...
- (C)*p++和*++p区别
接下来,通过示例彻底理解自增运算符的两种用法(自减的用法与之类似,只不过是加1变成了减1). 1.++i和i++的区别 如清单1(注意代码中的注释): #include <stdio.h> ...
- 跳转到AppStore 的不同位置办法
程序跳转到appstore中指定的应用 1.进入appstore中指定的应用NSString *str = [NSString stringWithFormat: ...
- CentOS7 安装和配置 mysql5.7
1.下载 mysql源安装包 wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm 2.安装mysql源 ...
- codeforces 459 A. Pashmak and Garden 解题报告
题目链接:http://codeforces.com/problemset/problem/459/A 题目意思:给出两个点的坐标你,问能否判断是一个正方形,能则输出剩下两点的坐标,不能就输出 -1. ...
- Linux网络编程笔记(修订版)
我的网络编程笔记, 因为最近又要做Linux下的网络编程,故重新修订, 其中一些内容参考了文末的链接及文章 1. 基本概念 2. 基本接口 2.1. 打开一个socket 2.2. 将 ...
- iOS多线程 NSThread/GCD/NSOperationQueue
无论是GCD,NSOperationQueue或是NSThread, 都没有线程安全 在需要同步的时候需要使用NSLock或者它的子类进行加锁同步 "] UTF8String], DISPA ...