P1348

Couple number

我其实找规律了的,然后也没仔细分析,这个题多巧妙。

C=a^2-b^2=(a+b)(a-b)

对于任意a而言,加减同一个数得到的数的奇偶性相同,故c=奇数或4的倍数。

考虑负数,(-3)%2==-1

  1. #include<iostream>
  2. using namespace std;
  3. long long l,r;
  4. long long ans;
  5. int main()
  6. {
  7. cin>>l>>r;
  8. for(long long i=l;i<=r;i++)
  9. if(i%2!=0||i%==)
  10. ans++;
  11. cout<<ans;
  12. return ;
  13. }

Couple number的更多相关文章

  1. JavaScript Math和Number对象

    目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...

  2. Harmonic Number(调和级数+欧拉常数)

    题意:求f(n)=1/1+1/2+1/3+1/4-1/n   (1 ≤ n ≤ 108).,精确到10-8    (原题在文末) 知识点:      调和级数(即f(n))至今没有一个完全正确的公式, ...

  3. Java 特定规则排序-LeetCode 179 Largest Number

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

  4. Eclipse "Unable to install breakpoint due to missing line number attributes..."

    Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...

  5. 移除HTML5 input在type="number"时的上下小箭头

    /*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-in ...

  6. iOS---The maximum number of apps for free development profiles has been reached.

    真机调试免费App ID出现的问题The maximum number of apps for free development profiles has been reached.免费应用程序调试最 ...

  7. 有理数的稠密性(The rational points are dense on the number axis.)

    每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.

  8. [LeetCode] Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球

    There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided ...

  9. [LeetCode] Number of Boomerangs 回旋镖的数量

    Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of po ...

  10. [LeetCode] Number of Segments in a String 字符串中的分段数量

    Count the number of segments in a string, where a segment is defined to be a contiguous sequence of ...

随机推荐

  1. 【通信】URLConnection 详细

    通信链接.程序可以通过URLConnection实例向该URL发送请求.读取URL引用的资源. 通常创建一个和 URL的连接,并发送请求.读取此URL引用的资源需要如下几个步骤: 通过调用URL对象o ...

  2. 2017-2018-2 20155303『网络对抗技术』Exp4:恶意代码分析

    2017-2018-2 20155303『网络对抗技术』Exp4:恶意代码分析 --------CONTENTS-------- 一.原理与实践说明 1.实践目标 2.实践内容概述 3.基础问题回答 ...

  3. 【转】OpenCV对图片中的RotatedRect进行填充

    函数名:full_rotated_rect 函数参数: image输入图像,rect希望在图像中填充的RotatedRect,color填充的颜色 主要的思路是:先找到RotatedRect的四个顶点 ...

  4. oracle 视图 参数

    创建包: create or replace package p_view_param  is   function set_param(num number) return number;   fu ...

  5. nagios系列(六)之nagios实现对服务器cpu温度的监控

    1.安装硬件传感器监控软件sensors yum install -y lm_sensors* 2.运行sensors-detect进行传感器检测 ##一路回车即可 Do you want to ov ...

  6. cocos creator 的scorllview 滑动事件和 子内容触摸事件会产生冲突

    1:问题描叙: UI上的 scorllview 的子元素需要拖动到游戏场景.所以子元素需要绑定触摸事件,scorllview 默认的事件处理方式就会和子元素的触摸事件冲突.2:解决方案: Scroll ...

  7. 100以内的质数(for和if)

  8. Hibernate 常用jar包 分析

    antlr-2.7.6.jar的作用 ANTLR (ANother Tool for Language Recognition) 是一个PCCTS制定的语言工具,它为他创建认定者,程序编译者,翻译者提 ...

  9. OCM_第二天课程:Section1 —》配置 Oracle 网络环境

    注:本文为原著(其内容来自 腾科教育培训课堂).阅读本文注意事项如下: 1:所有文章的转载请标注本文出处. 2:本文非本人不得用于商业用途.违者将承当相应法律责任. 3:该系列文章目录列表: 一:&l ...

  10. php中常用的正则表达式函数

    php中常用的正则表达式函数 * preg_match() * preg_match_all() * preg_replace() * preg_filter() * preg_grep() * pr ...