B - Arithmetic Progressions(待解决
https://vjudge.net/contest/394066#problem/B
https://vjudge.net/problem/Gym-102082B/origin
数据量大不能用数组查
用了二分,在test57的地方OT了,应该是算法有问题(待补题
附未通过代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <iomanip>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <iterator>
#include <utility>
#include <sstream>
#include <limits>
#include <numeric>
#include <functional>
using namespace std;
#define gc getchar()
#define mem(a) memset(a,0,sizeof(a))
#define debug(x) cout<<"debug:"<<#x<<" = "<<x<<endl; #define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef char ch;
typedef double db; const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int maxm=100+10;
const int N=1e6+10;
const int mod=1e9+7; ll a[5005] = {0};
bool find(ll key ,ll n)
{
int left = 1,right = n;
while(left <= right)
{
int mid = (left + right) / 2;
if(a[mid] == key)
return 1;
else if(a[mid] > key)
right = mid - 1;
else
left = mid + 1;
}
return 0;
} int main()
{
ll n = 0;
cin >> n;
for(ll i = 0;i<n;i++)
{
cin >> a[i];
}
sort(a,a+n); ll max = 0;
for(ll i = 0;i<n-1;i++)
{
for(ll j = i+1;j<n;j++)
{
ll counter = 0;
ll x = a[i] > a[j] ? a[i] : a[j];
ll y = a[i] < a[j] ? a[i] : a[j];
ll d = x - y;
ll temp = x + d;
while(find(temp,n) && temp <= 1e9)
{
temp += d;
counter += 1;
}
//cout<<x << " "<<y<<" "<<counter<<endl;
if(counter > max)max = counter;
}
}
cout << max+2;
return 0;
}
B - Arithmetic Progressions(待解决的更多相关文章
- [Educational Codeforces Round 16]D. Two Arithmetic Progressions
[Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...
- Dirichlet's Theorem on Arithmetic Progressions 分类: POJ 2015-06-12 21:07 7人阅读 评论(0) 收藏
Dirichlet's Theorem on Arithmetic Progressions Time Limit: 1000MS Memory Limit: 65536K Total Submi ...
- 洛谷P1214 [USACO1.4]等差数列 Arithmetic Progressions
P1214 [USACO1.4]等差数列 Arithmetic Progressions• o 156通过o 463提交• 题目提供者该用户不存在• 标签USACO• 难度普及+/提高 提交 讨论 题 ...
- POJ 3006 Dirichlet's Theorem on Arithmetic Progressions (素数)
Dirichlet's Theorem on Arithmetic Progressions Time Limit: 1000MS Memory Limit: 65536K Total Submi ...
- poj 3006 Dirichlet's Theorem on Arithmetic Progressions【素数问题】
题目地址:http://poj.org/problem?id=3006 刷了好多水题,来找回状态...... Dirichlet's Theorem on Arithmetic Progression ...
- (素数求解)I - Dirichlet's Theorem on Arithmetic Progressions(1.5.5)
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit cid=1006#sta ...
- USACO 1.4 Arithmetic Progressions
Arithmetic Progressions An arithmetic progression is a sequence of the form a, a+b, a+2b, ..., a+nb ...
- Educational Codeforces Round 16 D. Two Arithmetic Progressions (不互质中国剩余定理)
Two Arithmetic Progressions 题目链接: http://codeforces.com/contest/710/problem/D Description You are gi ...
- 等差数列Arithmetic Progressions题解(USACO1.4)
Arithmetic Progressions USACO1.4 An arithmetic progression is a sequence of the form a, a+b, a+2b, . ...
- E - Two Arithmetic Progressions(CodeForces - 710D)(拓展中国剩余定理)
You are given two arithmetic progressions: a1k + b1 and a2l + b2. Find the number of integers x such ...
随机推荐
- css实现居中对齐的几种方式
一般来说居中的话可分为水平居中与垂直居中,以下是我个人总结的几种方式 1.水平居中: inline元素:text-algin:center实现 block元素:margin:auto absolute ...
- 最炫酷的企业 AI 助手来啦(含前端源码)!
最近越来越多的企业开始将 MaxKB 在他们企业当中的应用场景官宣了.有时候我们会疑问,这真的是 MaxKB 做的吗? MaxKB 你怎么还能动的? 案例一:医疗资源小助手开场白 效果展示: 源码: ...
- 如何排查内存飙高-Linux top命令快速入门
Linux系统出现了性能问题,一般我们可以通过 top.iostat.free.vmstat和ifstat等命令来初步定位问题.其中,top命令是Linux下常用的性能分析工具,用于实时监测系统资 ...
- Gitee、Github上star星星数获取到一个图片里,用于MD文档
记录一下 Gitee 用这个链接当图片地址即可 https://gitee.com/用户名/仓库名/badge/star.svg?theme=white https://gitee.com/用户名/仓 ...
- mysql的递归写法:部门层级
前言 详细的可以参考:https://cloud.tencent.com/developer/article/2106748 这里用 WITH RECURSIVE 实现递归,需要 MySQL 8.0 ...
- 「Log」做题记录 2024.1.1-2024.1.28
\(2024.1.1-2024.1.7\) \(\color{blueviolet}{P1501}\) LCT 板子,链加链乘查询链和,断边加边. \(\color{black}{P4332}\) L ...
- python终端中使用pip指令下载模块显示SyntaxError: invalid syntax解决办法
今天学习爬虫导入模块时遇到以下错误,即语法错误 >>> pip bs4 File "<stdin>", line 1 pip bs4 ^^^ Synt ...
- spring的控制反转DI---基于注解实现
首先在pom.xml里面导入依赖: <dependencies> <!--要使用spring需要添加4个包但是maven会把他的几个依赖包同时下好--> <depende ...
- HTML常见的标签---表单
1 <table> 2 <tr> 3 <!-- name 一定要带上以后交互 --> 4 <td>用户名:</td> 5 <td> ...
- 生活中有苦难却没有人可以倾述?来看看AI树洞吧!
本文由 ChatMoney团队出品 介绍说明 在如今繁忙喧嚣的世界中,我们时常渴望能有一个安全且私密的空间,让我们毫无顾忌地袒露心声.AI 智能体树洞便是这样一个独特的存在. 它并非传统意义上的树洞, ...