水题。

#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
#include<cstdio>
using namespace std; long long k,L,R; int main()
{
scanf("%lld%lld%lld",&k,&L,&R);
long long ans;
if(L<&&R>) ans=R/k-L/k+;
else if(L==&&R==) ans=;
else if(L==)
{
ans=;
if(R>=k) ans=ans+R/k-k/k+;
}
else if(R==)
{
ans=;
swap(L,R); L=-L; R=-R;
if(R>=k) ans=ans+R/k-k/k+;
}
else if(L>)
{
if(R>=k)
{
long long left;
if(L%k!=) left=L/k+;
else left=L/k;
long long right=R/k; if(left>right) ans=;
else ans=right-left+;
}
else ans=;
}
else
{
swap(L,R); L=-L; R=-R;
if(R>=k)
{
long long left;
if(L%k!=) left=L/k+;
else left=L/k;
long long right=R/k; if(left>right) ans=;
else ans=right-left+;
}
else ans=;
}
printf("%lld\n",ans);
return ;
}

CodeForces 597A Divisibility的更多相关文章

  1. [math] Codeforces 597A Divisibility

    题目:http://codeforces.com/problemset/problem/597/A Divisibility time limit per test 1 second memory l ...

  2. Codeforces 550C —— Divisibility by Eight——————【枚举 || dp】

     Divisibility by Eight time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  3. codeforces 630J Divisibility

    J. Divisibility time limit per test 0.5 seconds memory limit per test 64 megabytes input standard in ...

  4. Codeforces 922F Divisibility 构造

    Divisibility 我们考虑删数字 首先我们可以发现有一类数很特殊就是大于 n / 2的素数, 因为这些素数的贡献只有1, 并且在n大的时候, 这些素数的个数不是很少, 我们可以最后用这些数去调 ...

  5. Codeforces 922F Divisibility (构造 + 数论)

    题目链接  Divisibility 题意 给定$n$和$k$,构造一个集合$\left\{1, 2, 3, ..., n \right\}$的子集,使得在这个集合中恰好有$k$对正整数$(x, y) ...

  6. Codeforces 988E. Divisibility by 25

    解题思路: 只有尾数为25,50,75,00的数才可能是25的倍数. 对字符串做4次处理,以25为例. a. 将字符串中的最后一个5移到最后一位.计算交换次数.(如果没有找到5,则不可能凑出25,考虑 ...

  7. HPU周赛题目解析

    A - Wilbur and Swimming Pool Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & ...

  8. Codeforces--597A--Divisibility(数学)

     DivisibilityCrawling in process... Crawling failed Time Limit:1000MS     Memory Limit:262144KB    ...

  9. Codeforces Round #306 (Div. 2) C. Divisibility by Eight 暴力

    C. Divisibility by Eight Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

随机推荐

  1. 安装mysql时 make 时 提示 redeclaration of C++ built-in type ‘bool’ 错误

    安装mysql时 make 时 提示 redeclaration of C++ built-in type ‘bool’ 错误 由于gcc-c++是在./configure后进行编译的 重新./con ...

  2. sql server 收缩日志文件

    USE 数据库名称 GO ALTER DATABASE 数据库名称 SET RECOVERY SIMPLE WITH NO_WAIT GO ALTER DATABASE 数据库名称 SET RECOV ...

  3. DROP CONVERSION - 删除一个用户定义的编码转换

    SYNOPSIS DROP CONVERSION name [ CASCADE | RESTRICT ] DESCRIPTION 描述 DROP CONVERSION 删除一个以前定义的编码转换. 要 ...

  4. Python中Pickle模块的dump()方法和load()方法

    Python中的Pickle模块实现了基本的数据序列与反序列化. 经常遇到在Python程序运行中得到了一些字符串.列表.字典等数据,想要长久的保存下来,方便以后使用,而不是简单的放入内存中关机断电就 ...

  5. OpenCV2:第二章 创建图像并显示

    一.简介 相当于在PS中,新建一个画布 二.CvMat类/LPLImage和CvMat结构体 参考: OpenCV2:第一章 图像表示 三.create() Mat m(2,2,CV_8UC3); m ...

  6. django insert data into mysql

    #!/usr/bin/python # -*- coding:utf-8 -*- # @filename: search # @author:wwx399777 wuweiji # @date: 20 ...

  7. ios NSRange

    Objective-C中判断字符串是否包含其他字符串 -(BOOL) hasPrefix:(NSString *) astring;检查字符串是否以astring开头:-(BOOL) hasSuffi ...

  8. git命令使用(一)

    作为程序员怎么能不了解git命令呢,但是由于本人不常用到git命令,现在的软件上也都一体化了,能够简化命令,直接运行都可以了,完全能够去实现git上的命令,导致输入git命令完全不会,git命令能够让 ...

  9. 纯html+css中实现静态选座位效果技巧(input+label使用小技巧)

    很多时候,我们想通过html+css的方式实现排列在后方的代码在选中状态下,能控制排列在前的代码的样式.那么要怎么实现呢?在这里我就要用1个小技巧来完成. 众所周知的,我们css中的选择器通常只能向下 ...

  10. 用户管理命令--useradd

    用户管理命令--useradd 作用:用于添加一个新的用户 格式:useradd [ 选项 ] 用户名 选项的常用介绍 -u: UID指定用户id,必须是唯一的,并且大于499 -c: 添加注释,可以 ...