题目链接: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. Connect4 Game

    How this game is playe can be found at here. public class Connect4 { ][]; public Connect4(char[][] b ...

  2. oracle学习笔记day2

    第三章:单值函数 函数分为: 1.单值函数 1.字符函数 2.日期函数 3.转换函数 4.数字函数 2.分组函数(后面的章节再做学习) 哑表dual dual是一个虚拟表,用来构成select的语法规 ...

  3. HashMap集合-遍历方法

    # HashMap集合-遍历方法 先定义好集合: public static void main(String[] args) { Map<String,String> onemap=ne ...

  4. 线段树维护动态连续子段HDU1540

    题意:http://acm.hdu.edu.cn/showproblem.php?pid=1540 #define IOS ios_base::sync_with_stdio(0); cin.tie( ...

  5. KeyValuePair<string, string>

    ; #region CUP Method /// <summary> /// 请求与响应的超时时间 /// </summary> static public int Timeo ...

  6. 怎样理解AJAX

    AJAX: Asynchronous JavaScript and XML, 翻译过来就是: 异步的JavaScript与XML 这已经成为了一个通用名词, 字面意义已经消失了, 因为现在使用Java ...

  7. 12-MySQL DBA笔记-MySQL复制

    第12章 MySQL复制 本章将为读者讲述MySQL的复制技术,首先,介绍最基础的主从复制,它是其他所有复制技术的基础,接着再为读者讲述各种复制架构的搭建,最后,列举了一些常见的复制问题及处理方式.复 ...

  8. 记一次邮件推送的坑,c#基于smtp使用腾讯企业邮箱发送邮件总是失败的原因

    今天在弄企业邮箱推送的东西,原版代码是这样的 public void SendEmail(string title, string content) { try { MailMessage mailM ...

  9. Hexo NexT主题内加入动态背景

    主题内新添加内容 _layout.swig 找到themes\next\layout\_layout.swig文件,添加内容:在<body>里添加: 1 2 3 <div class ...

  10. element之input输入搜索联想框

    1. 模板代码 <el-autocomplete :minlength="2" v-model="searchName" :fetch-suggestio ...