CodeForces 597A Divisibility
水题。
#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的更多相关文章
- [math] Codeforces 597A Divisibility
题目:http://codeforces.com/problemset/problem/597/A Divisibility time limit per test 1 second memory l ...
- Codeforces 550C —— Divisibility by Eight——————【枚举 || dp】
Divisibility by Eight time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- codeforces 630J Divisibility
J. Divisibility time limit per test 0.5 seconds memory limit per test 64 megabytes input standard in ...
- Codeforces 922F Divisibility 构造
Divisibility 我们考虑删数字 首先我们可以发现有一类数很特殊就是大于 n / 2的素数, 因为这些素数的贡献只有1, 并且在n大的时候, 这些素数的个数不是很少, 我们可以最后用这些数去调 ...
- Codeforces 922F Divisibility (构造 + 数论)
题目链接 Divisibility 题意 给定$n$和$k$,构造一个集合$\left\{1, 2, 3, ..., n \right\}$的子集,使得在这个集合中恰好有$k$对正整数$(x, y) ...
- Codeforces 988E. Divisibility by 25
解题思路: 只有尾数为25,50,75,00的数才可能是25的倍数. 对字符串做4次处理,以25为例. a. 将字符串中的最后一个5移到最后一位.计算交换次数.(如果没有找到5,则不可能凑出25,考虑 ...
- HPU周赛题目解析
A - Wilbur and Swimming Pool Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & ...
- Codeforces--597A--Divisibility(数学)
DivisibilityCrawling in process... Crawling failed Time Limit:1000MS Memory Limit:262144KB ...
- 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/ ...
随机推荐
- Understanding Scroll Views 深入理解 scroll view 读书笔记
Understanding Scroll Views 深入理解 scroll view 读书笔记 It may be hard to believe, but a UIScrollView is ...
- Oracle | Java日期处理
public class Test{ public static void main (String args []){ j ...
- Java集合类工具CollectionUtils的操作方法
集合判断: 例1: 判断集合是否为空:CollectionUtils.isEmpty(null): trueCollectionUtils.isEmpty(new ArrayList()): true ...
- python+selenium(环境的安装)
前言:网上的资料层次不齐,且资料也不全,容易误导新手,所以笔者愿意把你的知识免费分享给大家,笔者用的版本为:python3 此时可能新手就会问了,为什么不用python2呢,因为道理很简单,人要往前走 ...
- uva820 Internet Bandwidth
就是模板... #include<cstdio> #include<cstring> #include<vector> #include<queue> ...
- java GZIP压缩与解压缩
1.GZIP压缩 public static byte[] compress(String str, String encoding) { if (str == null || str.length( ...
- vue 自定义组件 v-model双向绑定、 父子组件同步通信【转】
父子组件通信,都是单项的,很多时候需要双向通信.方法如下: 1.父组件使用:msg.sync="aa" 子组件使用$emit('update:msg', 'msg改变后的值xxx ...
- largest rectangle in histogram leetcode
Given n non-negative integers representing the histogram's bar height where the width of each bar is ...
- web前端中的一些注释表达法
1.HTML注释 <!--注释的内容--> 注释的地方(根据个人习惯可能有所不同): 结束标签的后面,这一切都是为了程序在嵌套的时候更加方便.明了,如: <div class=&qu ...
- swift详解之九---------------自动引用计数、循环引用
自动引用计数.循环引用(这个必须理解,必须看) 注:本文详细介绍自动引用计数,以及各种循环引用问题.一网打尽! 1. 自动引用计数原理 Swift 使用ARC机制来跟踪和管理你的内存,一般情况下,Sw ...