题目链接:http://codeforces.com/contest/813/problem/B

题意:就是有一个数叫做不幸运数,满足题目的 n = x^a + y^b,现在给你一个区间[l,r],让你找一个在这个区间里面一个最长的区间使得这个区间里面的所有数都不是不幸运数,让你输出最长区间的区间长度 。

先用两个数组将x的n次方和y的n次方存起来,然后暴力枚举,用map将符合的条件的数存起来,不幸运数的区间就是两个幸运数的位置之差相减再减1。(注意map迭代器的用法)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1)
const int INF = 0x3f3f3f3f;
const ll N=1e18;
map<ll,ll>ma;
ll x[],y[]; int main()
{
memset(x,,sizeof(x));
memset(y,,sizeof(y));
ll a,b,l,r;
scanf("%I64d%I64d%I64d%I64d",&a,&b,&l,&r);
x[]=;
y[]=;
ma[l-]=;
ma[r+]=;
for(int i=; x[i-]<=N/a; i++)
x[i]=x[i-]*a;
for(int i=; y[i-]<=N/b; i++)
y[i]=y[i-]*b;
for(int i=; x[i]!=; i++)
for(int j=; y[j]!=; j++)
if(x[i]+y[j]<=r&&x[i]+y[j]>=l)
ma[x[i]+y[j]]=;
map<ll,ll>::iterator fir,sec;
sec=ma.begin();
fir=ma.begin();
sec++;
ll ans=;
for(; sec!=ma.end(); fir++,sec++)
ans=max(ans,sec->first-fir->first-);
printf("%I64d",ans);
return ;
}

Educational Codeforces Round 22 B. The Golden Age(暴力)的更多相关文章

  1. Educational Codeforces Round 22 E. Army Creation

    Educational Codeforces Round 22 E. Army Creation 题意:求区间[L,R]内数字次数不超过k次的这些数字的数量的和 思路:和求区间内不同数字的数量类似,由 ...

  2. Educational Codeforces Round 22.B 暴力

    B. The Golden Age time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  3. Educational Codeforces Round 22 补题 CF 813 A-F

    A The Contest 直接粗暴贪心 略过 #include<bits/stdc++.h> using namespace std; int main() {//freopen(&qu ...

  4. Educational Codeforces Round 22 E. Army Creation 主席树 或 分块

    http://codeforces.com/contest/813/problem/E 题目大意: 给出长度为n的数组和k,  大小是1e5级别. 要求在线询问区间[l, r]权值,  权值定义为对于 ...

  5. [Educational Codeforces Round#22]

    来自FallDream的博客,未经允许,请勿转载,谢谢. 晚上去clj博客逛来逛去很开心,突然同学提醒了一下,发现cf已经开始40分钟了,慌的一B,从B题开始写,写完了B到E最后收掉了A,结果太着急B ...

  6. 【Educational Codeforces Round 22】

    又打了一场EDU,感觉这场比23难多了啊…… 艹还是我太弱了. A. 随便贪心一下. #include<bits/stdc++.h> using namespace std; ,ans=- ...

  7. Educational Codeforces Round 22 E. Army Creation(分块好题)

    E. Army Creation time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  8. Codeforces Educational Codeforces Round 5 B. Dinner with Emma 暴力

    B. Dinner with Emma 题目连接: http://www.codeforces.com/contest/616/problem/A Description Jack decides t ...

  9. Educational Codeforces Round 11 D. Number of Parallelograms 暴力

    D. Number of Parallelograms 题目连接: http://www.codeforces.com/contest/660/problem/D Description You ar ...

随机推荐

  1. Kindergarten(网络流解法)

    题意:http://acm.hdu.edu.cn/showproblem.php?pid=2458 问你二分图的最大团是多大. #define IOS ios_base::sync_with_stdi ...

  2. Numpy学习之——数组创建

    Numpy学习之--数组创建 过程展示 import numpy as np a = np.array([2,3,9]) a array([2, 3, 9]) a.dtype dtype('int32 ...

  3. Django(一)安装启动

    Django下载/启动 1.下载安装 pip install django 或者 压缩文件下载地址:https://github.com/django/django/releases python s ...

  4. 使用Visual Studio2019 开启Openmp的方法

    调试-->属性-->C/C++-->所有选项-->Openmp支持改为 是(可以使用下拉菜单) 严重性 代码 说明 项目 文件 行 禁止显示状态 禁止显示状态 错误 C2338 ...

  5. 8-MySQL DBA笔记-测试基础

    第三部分 测试篇 测试需要掌握的知识面很广泛,本篇的关注点是数据库的性能测试和压力测试,对于其他领域的测试,由于涉猎不多,笔者就不做叙述了.DBA的工作职责之一就是评估软硬件,这往往是一项很耗时的工作 ...

  6. linux脚本监控应用且通过邮件报警异常

    一.背景 最近接到监控应用并通过邮件报警的任务,由于需求比较简单,故没有使用springboot那套,而是采用linux脚本的方式进行监控. 二.思路 通过linux自带的定时功能,定时执行一个lin ...

  7. php.ini中allow_url_fopen和allow_url_include的设置

    all_url_include在php 5.2以后添加,安全方便的设置(php的默认设置)为:allow_url_fopen=on;all_url_include=off;allow_url_fope ...

  8. EFcore的 基础理解<三> 多对多,唯一约束

    唯一约束,替代键. modelBuilder.Entity<Car>() .HasAlternateKey(c => new { c.State, c.LicensePlate }) ...

  9. 小程序wxs价格显示小数点后两位

    function toFix(data, val) { var numbers = ''; for (var i = 0; i < val; i++) { numbers += '0'; } v ...

  10. java中的多态总结

    一.多态的概述 ava作为面向对象的语言,同样可以描述一个事物的多种形态.如Student类继承了Person类,一个Student的对象便既是Student,又是Person. Java中多态的代码 ...