Codeforces Divisibility【水题】
1 second
256 megabytes
standard input
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.
The only line contains three space-separated integers k, a and b (1 ≤ k ≤ 1018; - 1018 ≤ a ≤ b ≤ 1018).
Print the required number.
1 1 10
10
2 -4 4
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【水题】相关推荐
- codeforces 1041a(水题)
http://codeforces.com/problemset/problem/1041/A(题目链接) There was an electronic store heist last night ...
- Codeforces 864 A Fair Game 水题
题目链接: http://codeforces.com/problemset/problem/864/A 题目描述: 看不是是不是一串数中只有两种数且这两种数字的数量是相同的 解题思路: 水题, 水过 ...
- 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 ...
- Educational Codeforces Round 7 B. The Time 水题
B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...
- 【CodeForces - 1A】Theatre Square(水题,几何)(CODEFORCES,梦的开始)
题干: Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters ...
- 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 ...
- Codeforces数据结构(水题)小结
最近在使用codeblock,所以就先刷一些水题上上手 使用codeblock遇到的问题 1.无法进行编译-------从setting中的编译器设置中配置编译器 2.建立cpp后无法调试------ ...
- 水题 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 < ...
- Codeforces//Good Bye 2013//A. New Year Candles 水题
第一次在Codeforces上提交题,全是英文,啊.应该是场比赛,WA了两次,丫的.哎,什么时候才能不做水题了呢.Happy New Year!Zhou Ping!努力奋斗! 题目链接:A. New ...
- CodeForces - 1293C NEKO's Maze Game(思维,水题)
题目链接:点击查看 题目大意:给出一个2*n大小的矩阵,现在有m次操作,每次操作将某一个方格的状态置反,这里的每个方块都有两种状态,一种状态是可通行状态,另一种是不可通行状态,初始时所有方块都是可通行 ...
最新文章
- Fedora20下安装编译环境
- LeetCode-剑指 Offer 14- I. 剪绳子
- AutoLISP 绘制表情图案
- 中科大 计算机网络4 网络核心Core 分组交换 电路交换
- 未能将管道连接到虚拟机: 所有的管道范例都在使用中。_山西大同超高压管道连接器维修方便厂家...
- (103)FPGA面试题-画出程序所描述的电路原理图(一)
- ICT学习笔记(1) 网络以及网络模型的相关知识
- 马斯克:2020 年底将完成 L5 级别自动驾驶功能
- Scrapy中的item是什么
- 小试牛刀之Kolla单节点部署
- こだわり者いろはちゃん / Iroha's Obsession (暴力枚举)
- 数据结构与程序的关系_java主程:数据结构和算法的区别别再搞混了,否则开除...
- 五分钟商学院(基础---商业篇)
- 【技术白皮书】第四章:信息抽取技术产业应用现状及案例(下)
- 双硬盘安装双系统详解
- linux系统怎么打开菜单,Linux如何编辑开始菜单
- 【软件工具篇02】使用Anki克服遗忘曲线
- C++类与对象——封装
- source insight 多文件并行显示
- 广西教育学院计算机技术专业可以当老师吗,广西教育学院老师待遇 广西教育学院好吗...