bzoj 4725 [POI2017]Reprezentacje ró?nicowe 暴力
[POI2017]Reprezentacje ró?nicowe
Time Limit: 10 Sec Memory Limit: 128 MB
Submit: 141 Solved: 67
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
17
18
Sample Output
16 15
HINT
Source
暴力跑出来,就log个数,然后随便乱搞,就可以了,枚举就好了,map存一下之类。
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<map>
#include<map> #define N 10007
#define it map<int,pair<int,int> >::iterator
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-;ch=getchar();}
while(isdigit(ch)){x=(x<<)+(x<<)+ch-'';ch=getchar();}
return x*f;
} map<int,pair<int,int> >s;
int Q,n,cnt;
int a[N],b[N]; int main()
{
a[]=,a[]=;
s[]=make_pair(,);
for(n=;;n++)
{
if(n&) a[n]=a[n-]*;
else for(int j=;;j++) if(!s.count(j)) { a[n]=a[n-]+j; break; }
for(int j=;j<n;j++) s[a[n]-a[j]]=make_pair(n,j);
if((!(n&))&&a[n]>1e9) break;
}
for(it l=s.begin();l!=s.end();l++)
b[++cnt]=l->first;
Q=read();
while(Q--)
{
int x=read();
it l=s.find(x);
if(l!=s.end())
printf("%d %d\n",(*l).second.first,(*l).second.second);
else
{
int y=lower_bound(b+,b+cnt+,x)-b-;
printf("%d %d\n",n+(x-y)*,n+(x-y)*-);
}
}
}
bzoj 4725 [POI2017]Reprezentacje ró?nicowe 暴力的更多相关文章
- BZOJ 4725: [POI2017]Reprezentacje ró?nicowe
Description 一个数列. \(a_1=1,a_2=2\) 当 \(n>2\) 时 \[a_n = \{ \begin {matrix} 2a_{n-1},\text{n is an ...
- BZOJ4725: [POI2017]Reprezentacje ró?nicowe
$n \leq 1e5$,$x \leq 1e9$. 1e9呵呵,暴力处理$a_n$的前几项直到1e9.然后处理出差的数列,每次在这里面找,找得到就回答,找不到,那有贡献的只有$a_i-a_{i-1} ...
- BZOJ 3339 & 莫队+"所谓的暴力"
题意: 给一段数字序列,求一段区间内未出现的最小自然数. SOL: 框架显然用莫队.因为它兹瓷离线. 然而在统计上我打了线段树...用&维护的结点...400w的线段树...然后二分查找... ...
- BZOJ 4727: [POI2017]Turysta
4727: [POI2017]Turysta Time Limit: 20 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 117 Solved ...
- bzoj 4724 [POI2017]Podzielno 二分+模拟
[POI2017]Podzielno Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 364 Solved: 160[Submit][Status][ ...
- BZOJ - 4066 KD树 范围计数 暴力重构
题意:单点更新,大矩阵(\(n*n,n≤10^5\))求和 二维的KD树能使最坏情况不高于\(O(N\sqrt{N})\) 核心在于query时判断当前子树维护的区间是否有交集/当前子节点是否在块中, ...
- BZOJ 4726: [POI2017]Sabota?
4726: [POI2017]Sabota? Time Limit: 20 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 301 Solved ...
- BZOJ 4723: [POI2017]Flappy Bird
Description 从一个点到一条直线,每次纵坐标只能增加或减少1,有些位置有障碍,求最少增加步数. Sol 贪心. 或许是贪心吧...反正在可到达的范围内,纵坐标尽量小... 做的时候维护一下两 ...
- BZOJ 4726: [POI2017]Sabota? 树形dp
4726: [POI2017]Sabota? 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4726 Description 某个公司有n ...
随机推荐
- 【shell 练习4】编写Shell用户管理脚本(二)
一.创建.删除.查看用户,随机生成八位数密码 #!/bin/bash #Author:yanglt #!/bin/bash #Author:yanglt #Blog:https://www.cnblo ...
- LeetCode - 442. Find All Duplicates in an Array - 几种不同思路 - (C++)
题目 题目链接 Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and ...
- 感知机(perceptron)
- Python高级编程-序列化
在程序运行的过程中,所有的变量都是在内存中,比如,定义一个dict: dict1 = {'name': 'Rob', 'age': 19, 'score': 90} 可以随时修改变量,比如把age改成 ...
- POJ 3608 Bridge Across Islands(计算几何の旋转卡壳)
Description Thousands of thousands years ago there was a small kingdom located in the middle of the ...
- Tarball——以源代码的方式安装软件
一.Tarball文件 形成:将软件的所有源码文件先以tar打包,然后再以压缩技术(如gzip)来压缩.因为源码文件很大. 描述:一个软件包,解压缩后得到源代码文件.检测程序文件.软件的简易说明与安装 ...
- 常用web资源
ip相关 新浪:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=220.181.38.110 (不带参数本机) ...
- Swift-函数的理解
/* 函数(Function) 函数是为执行特定功能的自包含的代码块.函数需要给定一个特定标识符(名字),然后当需要的时候, 就调用此函数来执行功能. */ // 函数的定义与调用 // 定义函数时, ...
- TCP系列22—重传—12、Forward Retransmit
一.概述 forward retransmit相关的内容在RFC6675中有描述,可以参考RFC6675 section 4中NextSeg ()的定义.forward retransmit中文名可以 ...
- Crash使用参考
整理自man 8 crash 1.简介 Crash工具可以用来分析一个正在运行的内核,也可以用来分析一个内核的crash dump文件,这里说的是内核代码异常产生的crash dump文件,不是应用层 ...