Codeforces--597A--Divisibility(数学)
2024-08-31 00:21:00
DivisibilityCrawling in process...
Crawling failed
Time Limit:1000MS
Memory Limit:262144KB
64bit IO Format:%I64d & %I64u
Description
Find the number of k-divisible numbers on the segment
[a, b]. In other words you need to find the number of such integer values
x that a ≤ x ≤ b and
x is divisible by k.
Input
The only line contains three space-separated integers k,
a and b (1 ≤ k ≤ 1018; - 1018 ≤ a ≤ b ≤ 1018).
Output
Print the required number.
Sample Input
Input
1 1 10
Output
10
Input
2 -4 4
Output
5
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
__int64 a,b,k;
while(scanf("%I64d%I64d%I64d",&k,&a,&b)!=EOF)
{
__int64 ans=0;
ans=b/k-a/k;
if(a==0&&b==0)
cout<<1<<endl;
else
{
if(a>=0&&b>=0&&a%k==0) ans++;
else if(a<=0&&b<=0&&b%k==0) ans++;
else if(a<=0&&b>=0) ans++;
printf("%I64d\n",ans);
}
}
return 0;
}
最新文章
- Mac常用终端命令
- MAC下搭建web开发环境
- asp.net读取xml方法
- windows 与Linux 互传文件
- css属性之vertical-align详解
- ABP官方文档翻译 5.1 Web API控制器
- css文字居中、图片居中、div居中解决方案
- 第二章	Idea搭建maven
- 高可用Redis(十三):Redis缓存的使用和设计
- Android绘制优化(一)绘制性能分析
- db2 OLAP函数使用
- Jmeter(二十八)Jmeter-Question之“HTTPS请求”
- 【Linux】CentOS7 安装,遇到的各种问题,并修复win7启动项
- Microsoft Dynamics CRM 常用JS语法(已转成vs2017语法提示)
- 安装ganglia过程中出现错误 perl(RRDp) is needed by rrdtool-1.2.30-1.el5.rf.x86_64
- [LeetCode] 58. Length of Last Word_Easy tag: String
- Luogu 3246 序列
- 如何在github上上传readme文件
- C#中的多线程 - 并行编程 z
- python科学计算整理
热门文章
- 从整体上理解进程创建、可执行文件的加载和进程执行进程切换,重点理解分析fork、execve和进程切换
- 服务器 获取用户 真实ip
- xilinx vivado 百度云分享 vivado2019.1 2018.3 2017.4
- Java基础——二分法
- Gym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)
- ubuntu 下安装wine
- Python pygame库的应用
- atCoder Ants on a Circle(又是蚂蚁问题。。。)
- Java Arrays.sort相关用法与重载
- 这个贴子的内容值得好好学习--实例详解Django的 select_related 和 prefetch_related 函数对 QuerySet 查询的优化