Codeforces Round #439 (Div. 2) Problem B (Codeforces 869B)
Even if the world is full of counterfeits, I still regard it as wonderful.
Pile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this.
The phoenix has a rather long lifespan, and reincarnates itself once every a! years. Here a! denotes the factorial of integer a, that is, a! = 1 × 2 × ... × a. Specifically, 0! = 1.
Koyomi doesn't care much about this, but before he gets into another mess with oddities, he is interested in the number of times the phoenix will reincarnate in a timespan of b! years, that is, . Note that when b ≥ a this value is always integer.
As the answer can be quite large, it would be enough for Koyomi just to know the last digit of the answer in decimal representation. And you're here to provide Koyomi with this knowledge.
The first and only line of input contains two space-separated integers a and b (0 ≤ a ≤ b ≤ 1018).
Output one line containing a single decimal digit — the last digit of the value that interests Koyomi.
2 4
2
0 10
0
107 109
2
In the first example, the last digit of is 2;
In the second example, the last digit of is 0;
In the third example, the last digit of is 2.
题目大意 给定a和b求b的阶乘除以a的阶乘的商的末尾数字。
显然,当a和b的差大于等于10的时候结果为0.
当a和b的差小于10的时候,暴力计算就好了(当然,不是把a!和b!)。
Code
/**
* Codeforces
* Problem#869B
* Accepted
* Time: 30ms
* Memory: 0k
*/
#include <bits/stdc++.h>
#ifndef WIN32
#define Auto "%lld"
#else
#define Auto "%I64d"
#endif
using namespace std; long long a, b; inline void init() {
scanf(Auto""Auto, &a, &b);
} inline void solve() {
if(b - a > ) puts("");
else {
int res = ;
for(int i = b % , c = ; c < b - a; c++, i = (i + ) % ) {
res = (res * i) % ;
}
printf("%d\n", res);
}
} int main() {
init();
solve();
return ;
}
Codeforces Round #439 (Div. 2) Problem B (Codeforces 869B)的更多相关文章
- Codeforces Round #439 (Div. 2) Problem E (Codeforces 869E) - 暴力 - 随机化 - 二维树状数组 - 差分
Adieu l'ami. Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around ...
- Codeforces Round #439 (Div. 2) Problem C (Codeforces 869C) - 组合数学
— This is not playing but duty as allies of justice, Nii-chan! — Not allies but justice itself, Onii ...
- Codeforces Round #439 (Div. 2) Problem A (Codeforces 869A) - 暴力
Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-sc ...
- Codeforces Round #439 (Div. 2)【A、B、C、E】
Codeforces Round #439 (Div. 2) codeforces 869 A. The Artful Expedient 看不透( #include<cstdio> in ...
- Codeforces Round #716 (Div. 2), problem: (B) AND 0, Sum Big位运算思维
& -- 位运算之一,有0则0 原题链接 Problem - 1514B - Codeforces 题目 Example input 2 2 2 100000 20 output 4 2267 ...
- Codeforces Round #753 (Div. 3), problem: (D) Blue-Red Permutation
还是看大佬的题解吧 CFRound#753(Div.3)A-E(后面的今天明天之内补) - 知乎 (zhihu.com) 传送门 Problem - D - Codeforces 题意 n个数字,n ...
- Codeforces Round #771 (Div. 2), problem: (B) Odd Swap Sort
Problem - B - Codeforces 就是给你个序列, 给他整成升序的, 每次操作可以使相邻两个数交换位置, 交换条件是二数之和为奇数 结果只需输出是否可以整成升序的 思路: 需要奇数偶数 ...
- Codeforces Round #306 (Div. 2), problem: (B) Preparing Olympiad【dfs或01枚举】
题意: 给出n个数字,要求在这n个数中选出至少两个数字,使得它们的和在l,r之间,并且最大的与最小的差值要不小于x.n<=15 Problem - 550B - Codeforces 二进制 利 ...
- Codeforces Round #754 (Div. 2), problem: (A) A.M. Deviation泪目 万万没想到狂wa是因为这
Problem - A - Codeforces 题目 题意很简单每次操作可以使得a1 a2 a3任意两个数分别+1 -1 求最后使得a+c-2b绝对值的最小值 BUG就是最后忽略了-2和2这一点 ...
随机推荐
- vue中打印显示++的问题解决方案(做成类似同步的操作就行了)
这个问题,困扰我很久很久 怎么实现的呢?首先进入页面就开始调取打印接口,打印接口的成功回调函数里面写 this.hasOut++(这是实时显示的数量)this.width=(this.hasOut/t ...
- WebService/WCF/WebAPI 之间的区别
Web Service 1.数据的格式基于SOAP协议 2.数据的传输只支持HTTP协议 3.它只能部署在IIS上 WCF 1.数据的格式基于SOAP协议 2.数据的传输支持HTTP,HTTPS,TC ...
- node.js初识01
1.对于node.js的安装在这里就不做过多的介绍了,安装成功后,可以通过cmd 输入node -v查看node的版本号,如图所示 2.开始我们的hello world,通过cmd进入所属文件夹,输入 ...
- UVAL 4728 Squares(旋转卡壳)
Squares [题目链接]Squares [题目类型]旋转卡壳 &题解: 听着算法名字,感觉挺难,仔细一看之后,发现其实很简单,就是依靠所构成三角行面积来快速的找对踵点,就可以省去很多的复杂 ...
- MyBatis基础入门《十七》动态SQL
MyBatis基础入门<十七>动态SQL 描述: >> 完成多条件查询等逻辑实现 >> 用于实现动态SQL的元素主要有: > if > trim > ...
- 学习笔记<2>Android基本四大组件
<1>Activity(活动) ------与用户交互的界面 (1)Activity启动基本流程 <2>service(服务) <3>ContentProvider ...
- 反射(I)
反射获取属性和属性值 let item = DoctorGroup() guard let dic = InterfaceTests.obtainValues(subObject: item) els ...
- HTTPS 之共享秘钥 公钥 及 私钥
HTTPS 之共享秘钥 公钥 及 私钥一 共享秘钥1.1 概念共享秘钥和我们生活中同一把锁的钥匙概念类似,对同一把锁来说,加锁时使用什么钥匙,解锁也必须使用同样的钥匙. 1.2 共享秘钥在HTTP传输 ...
- EasyUi通过OCUpload上传及POI上传 实现导入xls表格功能
Easyui上传文件案例 第一步:要想使用OCUpload首先前端需要导入js包 <script type="text/javascript" src=&qu ...
- 转:三值逻辑与NULL的处理方式
来自:<Microsoft SQL SERVER 2008技术内幕 T-SQL查询>P7 在SQL中谓词(逻辑表达式)的可能值为TRUE.FALSE和UNKNOWN.这就是所谓的三值逻辑, ...