A. Divisibility
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 thata ≤ x ≤ b and x is divisible by k.

Input

The only line contains three space-separated integers ka and b (1 ≤ k ≤ 1018; - 1018 ≤ a ≤ b ≤ 1018).

Output

Print the required number.

Examples
input
1 1 10

output
10

input
2 -4 4

output
5

#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <stack>
#include <cmath>
#include <vector>
#include <cstdlib>
//#include <bits/stdc++.h>
#define space " "
using namespace std;
typedef long long LL;
//typedef __int64 Int;
typedef pair<int,int> paii;
const int INF = 0x3f3f3f3f;
const double ESP = 1e-5;
const double Pi = acos(-1);
const int MOD = 1e9+5;
const int MAXN = 1e5;
long long k, a, b, ans;
int main() {while (scanf("%lld%lld%lld", &k, &a, &b) != EOF) {ans = 0; if ((a > 0 && b > 0) || (a < 0 && b < 0)) {ans += abs(b/k); ans -= abs(a/k);if (ans < 0) ans = -ans;if (min(abs(a), abs(b))%k == 0) ans++;}else {ans += abs(b/k); ans += abs(a/k);ans++;}printf("%lld\n", ans);}return 0;
}

转载于:https://www.cnblogs.com/cniwoq/p/6770805.html

Codeforces Divisibility【水题】相关推荐

  1. codeforces 1041a(水题)

    http://codeforces.com/problemset/problem/1041/A(题目链接) There was an electronic store heist last night ...

  2. Codeforces 864 A Fair Game 水题

    题目链接: http://codeforces.com/problemset/problem/864/A 题目描述: 看不是是不是一串数中只有两种数且这两种数字的数量是相同的 解题思路: 水题, 水过 ...

  3. Codeforces Round #355 (Div. 2) B. Vanya and Food Processor 水题

    B. Vanya and Food Processor 题目连接: http://www.codeforces.com/contest/677/problem/B Description Vanya ...

  4. Educational Codeforces Round 7 B. The Time 水题

    B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...

  5. 【CodeForces - 1A】Theatre Square(水题,几何)(CODEFORCES,梦的开始)

    题干: Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters ...

  6. Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake 水题

    A. Far Relative's Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/A Description Do ...

  7. Codeforces数据结构(水题)小结

    最近在使用codeblock,所以就先刷一些水题上上手 使用codeblock遇到的问题 1.无法进行编译-------从setting中的编译器设置中配置编译器 2.建立cpp后无法调试------ ...

  8. 水题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas

    题目传送门 1 /* 2 水题:ans = (1+2+3+...+n) * k - n,开long long 3 */ 4 #include <cstdio> 5 #include < ...

  9. Codeforces//Good Bye 2013//A. New Year Candles 水题

    第一次在Codeforces上提交题,全是英文,啊.应该是场比赛,WA了两次,丫的.哎,什么时候才能不做水题了呢.Happy New Year!Zhou Ping!努力奋斗! 题目链接:A. New ...

  10. CodeForces - 1293C NEKO's Maze Game(思维,水题)

    题目链接:点击查看 题目大意:给出一个2*n大小的矩阵,现在有m次操作,每次操作将某一个方格的状态置反,这里的每个方块都有两种状态,一种状态是可通行状态,另一种是不可通行状态,初始时所有方块都是可通行 ...

最新文章

  1. Fedora20下安装编译环境
  2. LeetCode-剑指 Offer 14- I. 剪绳子
  3. AutoLISP 绘制表情图案
  4. 中科大 计算机网络4 网络核心Core 分组交换 电路交换
  5. 未能将管道连接到虚拟机: 所有的管道范例都在使用中。_山西大同超高压管道连接器维修方便厂家...
  6. (103)FPGA面试题-画出程序所描述的电路原理图(一)
  7. ICT学习笔记(1) 网络以及网络模型的相关知识
  8. 马斯克:2020 年底将完成 L5 级别自动驾驶功能
  9. Scrapy中的item是什么
  10. 小试牛刀之Kolla单节点部署
  11. こだわり者いろはちゃん / Iroha's Obsession (暴力枚举)
  12. 数据结构与程序的关系_java主程:数据结构和算法的区别别再搞混了,否则开除...
  13. 五分钟商学院(基础---商业篇)
  14. 【技术白皮书】第四章:信息抽取技术产业应用现状及案例(下)
  15. 双硬盘安装双系统详解
  16. linux系统怎么打开菜单,Linux如何编辑开始菜单
  17. 【软件工具篇02】使用Anki克服遗忘曲线
  18. C++类与对象——封装
  19. source insight 多文件并行显示
  20. 广西教育学院计算机技术专业可以当老师吗,广西教育学院老师待遇 广西教育学院好吗...

热门文章

  1. 未来之路—写在大二结束之前
  2. mysql查询索引like_mysql 索引与优化like查询
  3. sql insert 自动增量值_SQL中有关DQL、DML、DDL、DCL的概念与区别
  4. 武汉linux驱动培训转让,linux驱动培训靠谱吗
  5. iis7 php安装教程,iis7 php安装方法详解
  6. 僵尸进程的产生与处理
  7. 切客软件诞生,给切客全新的购物消费体验
  8. Redis自带压测工具(redis-benchmark.exe)
  9. No changes detected
  10. Java NIO:IO与NIO的区别