SSL2810 2017年10月30日提高组T2 数论(math)
2017-10-30 19:37
218 查看
2017年10月30日提高组T2 数论
Description聪明的0v0正在学习莫比乌斯反演。
她看到了这样的一道题:有n*m个人站成了一个n*m的方阵……
剩下的题面,聪明的0v0不记得了。但是,她通过自己高超的数论技巧,给出了一个转化后的模型:给出n和m,求
聪明的0v0当然知道怎么做了,但是她想考考你。
Input
一行三个正整数n,m,p。
Output
一行一个非负整数,设答案为x,输出x mod p。
Sample Input
1 2 998244353
Sample Output
2
Hint
【数据规模和约定】
30% n,m<=2000 p=998244353。
30% n*m<=10^9 n,m<=10^5 p为质数
20% n,m<=10^6 p为质数
20% n,m<=10^7 p为合数
对于所有数据,保证p<=10^9
分析:打表发现,答案就是 n*m mod p。 其实,原式的物理意义,就是从坐标原点(0,0),用每一种合 法的斜率,穿过坐标[1~n,1~m]的方阵中的整点的个数,总数即 n*m。
代码
#include <cstdio> using namespace std; long long n,m,k; int main() { // freopen("math.in","r",stdin); // freopen("math.out","w",stdout); scanf("%d%d%d",&n,&m,&k); printf("%d",n*m%k); fclose(stdin); fclose(stdout); }
相关文章推荐
- 【SSLGZ 2810】2017年10月30日提高组T2 数论
- SSL2812 2017年10月30日提高组T2 凤凰院凶真(dp,LCIS)
- SSL2688 2017年8月14日提高组T2 温度
- SSL2694 2017年8月15日提高组T1 字符串(math,组合数取模)
- SSL2783 2017年10月23日提高组T1 摆书(math)
- 2017年10月30日提高组T1 数论
- SSL2774 2017年10月19日提高组 青蛙(math)
- SSL2795 2017年10月26日提高组T2 幸运值(组合)
- SSL2706 2017年8月17日提高组T2 考试(贪心)
- SSL2837 2017年11月6日提高组T1 互质(math)
- SSL2845 2017年11月8日提高组T2 序列操作(贪心,树状数组,差分)
- SSL2683 2017年8月12日提高组T2 YMW的数学题(math)
- SSL2843 2017年11月8日提高组T2 拆网线(树形dp)
- SSL2681 2017年8月11日提高组T3 难题(math)
- SSL2844 2017年11月8日提高组T2 奇怪的队列(线段树贪心)
- SSL2759 2017年10月6日提高组T2 挖矿(dp)
- SSL2677 2017年8月10号提高组T2 飞行(spfa)
- 【SSLGZ 2811】2017年10月30日提高组T2 摘Galo
- SSL2684 2017年8月12日提高组T3 YMW的三角形(math)
- SSL2790 2017年10月25日提高组T2 次方的运算(math)