第一次做CF,第一次用STL,纪念一下!

Codeforces Beta Round #62

A. Irrational problem

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Little Petya was given this problem for homework:

You are given function (here represents the operation of taking the remainder). His task is to count the number of integers x in range [a;b] with property f(x) = x.

It is a pity that Petya forgot the order in which the remainders should be taken and wrote down only 4 numbers. Each of 24 possible orders of taking the remainder has equal probability of being chosen. For example, if Petya has numbers 1, 2, 3, 4 then he can take remainders in that order or first take remainder modulo 4, then modulo 2, 3, 1. There also are 22 other permutations of these numbers that represent orders in which remainder can be taken. In this problem 4 numbers wrote down by Petya will be pairwise distinct.

Now it is impossible for Petya to complete the task given by teacher but just for fun he decided to find the number of integers with property that probability that f(x) = x is not less than 31.4159265352718281828459045%. In other words, Petya will pick up the number x if there exist at least 7 permutations of numbers p1, p2, p3, p4, for which f(x) = x.

Input

First line of the input will contain 6 integers, separated by spaces: p1, p2, p3, p4, a, b (1 ≤ p1, p2, p3, p4 ≤ 1000, 0 ≤ a ≤ b ≤ 31415).

It is guaranteed that numbers p1, p2, p3, p4 will be pairwise distinct.

Output

Output the number of integers in the given range that have the given property.

Sample test(s)
Input
2 7 1 8 2 8

Output
0

Input
20 30 40 50 0 100

Output
20

Input
31 41 59 26 17 43

Output
9

#include<cstdio> #include<algorithm> #include<cstdlib> #include<iostream> using namespace std; int main(void) { int a,b; int count,p[4]; while(scanf("%d%d%d%d%d%d",&p[0],&p[1],&p[2],&p[3],&a,&b) == 6) { int nums = 0; for(int t = a;t <= b; t++) { count = 0; sort(p,p+4); do { int n = t; for(int i = 0;i < 4;i++) n %= p[i]; if(n == t) count++; }while(next_permutation(p,p+4)); if(count >= 7) nums++; } cout << nums; } return 0; }

比着刘汝佳白皮书上的下一个排列写的,继续努力吧!

Irrational problem相关推荐

  1. linux下yum错误:[Errno 14] problem making ssl connection Trying other mirror.

    所有的base 都要取消注释 mirrorlist 加上注释 另外所有的enable都要设为零 目录 今天是要yum命令安装EPEL仓库后 yum install epel-release 突然发现y ...

  2. A + B Problem

    1001: A + B Problem Description 计算 A + B. Input 多组测试数据,每组测试数据占一行,包括2个整数. Output 在一行中输出结果. Sample Inp ...

  3. Error:(49, 1) A problem occurred evaluating project ':guideview'. Could not read script 'https://r

    出现问题如下: Error:(49, 1) A problem occurred evaluating project ':guideview'. > Could not read script ...

  4. #418 Div2 Problem B An express train to reveries (构造 || 全排列序列特性)

    题目链接:http://codeforces.com/contest/814/problem/B 题意 : 有一个给出两个含有 n 个数的序列 a 和 b, 这两个序列和(1~n)的其中一个全排列序列 ...

  5. ADPRL - 近似动态规划和强化学习 - Note 3 - Stochastic Infinite Horizon Problem

    Stochastic Infinite Horizon Problem 3.Stochastic Infinite Horizon Problem 定义3.1 无限范围的马尔可夫决策过程 (Marko ...

  6. ADPRL - 近似动态规划和强化学习 - Note 2 - Stochastic Finite Horizon Problem

    2. Stochastic Finite Horizon Problem 在这一节中主要介绍了随机DP算法来解决不确定性下的有限地范围问题,如Denition 1.4所述,它被表述为一个组合优化问题. ...

  7. There was a problem confirming the ssl certificate ……

    在安装一个Python库onetimepass时发生下面的问题: pip install onetimepass Could not fetch URL https://pypi.python.org ...

  8. HDU 1757 A Simple Math Problem

    Problem Description Lele now is thinking about a simple function f(x). If x < 10 f(x) = x. If x & ...

  9. The C10K problem原文翻译

    原文地址:http://www.cnblogs.com/fll/archive/2008/05/17/1201540.html The C10K problem 如今的web服务器需要同时处理一万个以 ...

  10. This is probably not a problem with npm. There is likely additional logging output above

    微信小程序开发交流qq群   173683895    承接微信小程序开发.扫码加微信. E:\weii_objct\invoice-manage-web-view>npm start > ...

最新文章

  1. 《深入理解计算机系统》第七章——链接知识点总结
  2. web前端开发培训完就业前景怎么样
  3. [原]SQL解决“俯瞰金字塔”矩阵
  4. HMAC-MD5算法原理及实现
  5. 盒模型的属性丶display显示丶浮动
  6. 深入了解Kubernetes REST API的工作方式
  7. 三维点云学习(1)上-PCA主成分分析 法向量估计
  8. 引入html页面比较,前端页面如何引入公用的页面header和footer
  9. 小明利用计算机软件绘制函数,辽宁省大连市2014年高二学业水平模拟考试 信息技术试题(三)...
  10. 简要罗列通过Allegro绘制的PCB封装步骤
  11. phpQuery占用过多内存的解决方法
  12. Linux下go环境安装、环境配置并执行第一个go程序
  13. python 解压文件 重名_Python批量重命名压缩文件
  14. SRAM随机存储器的特点及结构
  15. 区块链 01(简化后的区块包括父区块哈希值、数据、时间戳、哈希值这四个字段,区块的哈希值由父区块哈希值、数据、时间戳、3个字段拼接通过 哈希算法计算而成)
  16. 自由能计算专题3:gromacs计算自由能的7种方法案例
  17. dropdownlist下拉框变透明_Unity3D 4.x利用原生UGUI完成下拉列表DropDownList
  18. ”高内聚 ,低耦合“到底是什么意思?
  19. C++设计模式——装饰着模式(高屋建瓴)
  20. 操作系统的作用是什么?目前主流的操作系统有哪些?主要特点是什么?

热门文章

  1. android 局域网socket,Android基于局域网socket通信
  2. 一名运维工程师的第一个五年
  3. 20180310华为面试
  4. 【二〇二〇·秋】读书笔记
  5. python-opencv的一些基础操作
  6. 电路设计软件系列教程(五),Protel DXP电路设计软件之设计规则(上)
  7. 移动视频录传-公网对讲APP-MCP常见操作说明
  8. win7免费升级win10(正版)!!!
  9. HTML5中weight属性的作用,weight属性
  10. (Scrapy框架)爬虫获取新冠疫情数据升级版 | 爬虫案例