MemSQL start[c]up Round 1 B题
题目链接 http://codeforces.com/contest/325/problem/B
第一遍写了暴搜,果断TLE
然后上了二分,结果120组数据只有第40组过不了,我就写了奇怪的东西。。。。
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;
long long n;
long long a,b;
long long l,r;
long long x;
vector<long long>V;
int main()
{
while(scanf("%I64d",&n)!=EOF)
{
if(n==)
{printf("2828427124\n");continue;}
V.clear();
for(a=;a<=;a++)
{
if(((1LL<<a)-)>n) break;
l=;r=;
while(l<r)
{
b=(l+r)/;
x=((b-)*b)/+((1LL<<a)-)*b;
if(x<||x>=n||(b-)*b/<||((1LL<<a)-)*b<||((1LL<<a)-)<)
r=b;
else
l=b+;
}
if(((((r-)*r)/+((1LL<<a)-)*r)==n)&&(r%==))
V.push_back((1LL<<a)*r);
}
if(V.empty())
printf("-1\n");
else
for(size_t i=;i<V.size();i++)
printf("%I64d\n",V[i]);
}
return ;
}
附上CF里神牛们的CODE
还没想明白为何第40组过不了
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
long long z,l,r,h,x,k,n;
vector<long long> a;
int main() {
scanf("%I64d",&n);
for (k=; k<=; k++) {
z=(1LL<<k)-;
if (z>n) break;
l=; r=min(2000000000LL,z==?2000000000LL:(n/z+));
while (l<r) {
h=(l+r)/;
x=(h*(h-1LL))/+h*z;
if (x>=n) r=h; else l=h+;
}
x=(r*(r-1LL))/+r*z;
if (x==n && r%==) a.push_back(r*(z+));
}
sort(a.begin(),a.end());
if (a.empty()) puts("-1"); else for (size_t i=; i<a.size(); i++) printf("%I64d\n",a[i]);
return ;
}
MemSQL start[c]up Round 1 B题的更多相关文章
- MemSQL start[c]up Round 2 - online version C. More Reclamation(博弈)
题目大意 额,写来写去,我还是直接说抽象之后的题目大意吧: 有一个 r*2 的矩形,两个人轮流的在矩形上面减去一个 1*1 的小正方形,要求在减的过程中,不能使矩形“断开”,也就是说,如果一个人减去了 ...
- MemSQL start[c]up Round 1.b
二分查找题, 不知道用double的人,用LL果断错了... B. Stadium and Games time limit per test 1 second memory limit per te ...
- codeforces 659A A. Round House(水题)
题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...
- BestCoder Round #89 B题---Fxx and game(单调队列)
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5945 问题描述 输入描述 输出描述 输入样例 输出样例 题意:中文题,不再赘述: 思路: B ...
- Educational Codeforces Round 15 套题
这套题最后一题不会,然后先放一下,最后一题应该是大数据结构题 A:求连续最长严格递增的的串,O(n)简单dp #include <cstdio> #include <cstdlib& ...
- Educational Codeforces Round 21 A-E题题解
A题 ............太水就不说了,贴下代码 #include<string> #include<iostream> #include<cstring& ...
- Educational Codeforces Round 27 补题
题目链接:http://codeforces.com/contest/845 A. Chess Tourney 水题,排序之后判断第n个元素和n+1个元素是不是想等就可以了. #include < ...
- Codeforces Round #456 B题
一.题意 给你一个n和一个k,让你从[1, n]区间内选k个数,这k个数异或和最大. 二.思路 我一开始看到这种题,不自觉地就想到,莫非又要搞很复杂的线段树.主席树?貌似还有些难搞啊.然而事实是:Co ...
- Codeforces Round #346 (Div. 2) A. Round House 水题
A. Round House 题目连接: http://www.codeforces.com/contest/659/problem/A Description Vasya lives in a ro ...
随机推荐
- Singapore retailer will release this adidas NMD R1
Select spots are restocking the adidas NMD Singapore this Friday, Feb 24th featuring three different ...
- 2018 China Collegiate Programming Contest Final (CCPC-Final 2018)
Problem A. Mischievous Problem Setter 签到. #include <bits/stdc++.h> using namespace std; #defin ...
- spring整合ehcache 注解实现查询缓存,并实现实时缓存更新或删除
写在前面:上一篇博客写了spring cache和ehcache的基本介绍,个人建议先把这些最基本的知识了解了才能对今天主题有所感触.不多说了,开干! 注:引入jar <!-- 引入ehcach ...
- BZOJ2938:[POI2000]病毒(AC自动机)
Description 二进制病毒审查委员会最近发现了如下的规律:某些确定的二进制串是病毒的代码.如果某段代码中不存在任何一段病毒代码,那么我们就称这段代码是安全的.现在委员会已经找出了所有的病毒代码 ...
- 20145319 《网络渗透》MS11-050漏洞渗透
20145319 <网络渗透>MS11-050漏洞渗透 一 实验内容 初步掌握平台matesploit的使用 有了初步完成渗透操作的思路 了解MS11_050相关知识: - 安全公告:KB ...
- Yii框架(二)Model处理数据
熟悉php的autoload机制,自己实现一个autoload函数 一.复习框架: basic/ 应用根目录 composer.json Composer 配置文件, 描述包信息 config/ 包含 ...
- mygene 3.0.0
MyGene.Info provides simple-to-use REST web services to query/retrieve gene annotation data. It’s de ...
- BZOJ 1566 【NOI2009】 管道取珠
题目链接:管道取珠 这道题思路还是很巧妙的. 一开始我看着那个平方不知所措……看了题解后发现,这种问题有一类巧妙的转化.我们可以看成两个人来玩这个游戏,那么答案就是第二个人的每个方案在第一个人的所有方 ...
- 使用由 Intel MKL 支持的 R
我们通常使用的 R 版本是单线程的,即只使用一个 CPU 线程运行所有 R 代码.这样的好处是运行模型比较简单且安全,但是它并没有利用多核计算.Microsoft R Open(MRO,https:/ ...
- SQL Server2012创建约束图解
SQLServer中有五种约束:Primary Key约束.Foreign Key约束.Unique约束.Default约束和Check约束 1 . Primary Key 约束 在 ...