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 ...
随机推荐
- 限制可编辑div只能输入纯文本
本博客转载自张鑫旭大神的一篇文章:小tip: 如何让contenteditable元素只能输入纯文本,原文地址:http://www.zhangxinxu.com/wordpress/2016/01/ ...
- cocos代码研究(8)持续动作子类学习笔记
理论部分 时间间隔动作(ActionInterval)是一个在一段时间内执行的动作. 它有一个开始时间和完成时间.完成时间等于起始时间加上持续时间. ActionInterval的子类与位置有关的动作 ...
- http之状态码含义
状态代码有三位数字组成,第一个数字定义了响应的类别,共分五种类别: 1xx:指示信息--表示请求已接收,继续处理 2xx:成功--表示请求已被成功接收.理解.接受 3xx:重定向--要完成请求必须进行 ...
- uva672
Gangsters N gangsters are going to a restaurant. The i-th gangster comes at the time Ti and has t ...
- supervisor安装及其配置
一.supervisor概述 supervisor是一个c/s系统,被用来在类Unix系统中监控进程状态.supervisor使用python开发. 服务端进程为supervisord,主要负责启动自 ...
- Ubuntu16.04安装wireshark
Wireshark是一个非常强大的抓包工具,适用于各种场合,安装配置也简单.这里仅对在Ubuntu上的安装做介绍. 首先通过apt安装WireShark: $ sudo apt-add-reposit ...
- UVA10529 Dumb Bones
UVA10529 Dumb Bones go to solution 设$f[i]$表示叠$i$个的骨牌的期望 $O(n)$做法 #include<iostream> #include&l ...
- 基于OpenCV进行图像拼接原理解析和编码实现(提纲 代码和具体内容在课件中)
一.背景 1.1概念定义 我们这里想要实现的图像拼接,既不是如题图1和2这样的"图片艺术拼接",也不是如图3这样的"显示拼接",而是实现类似"BaiD ...
- UVa 10943 全加和
https://vjudge.net/problem/UVA-10943 题意: 把K个不超过N的非负整数加起来,使得它们的和为N,有多少种方法? 思路: d[i][j]表示用i个数加起来为j的方法数 ...
- Eclipse插件Fat Jar
1.安装 1)Eclipse在线更新方法 Help > Install New Software > Add, name:Fat Jar location:http://kurucz-gr ...