题目大意
聪明的0v0正在学习莫比乌斯反演。
她看到了这样的一道题:有$n\times m$个人站成了一个$n\times m$的方阵……
剩下的题面,聪明的0v0不记得了。但是,她通过自己高超的数论技巧,给出了一个转化后的模型:给出$n$和$m$,求
聪明的0v0当然知道怎么做了,但是她想考考你。
题目分析
题目可以转化为在$n\times m$的方阵上,选出坐标互质的点,并扩展其倍数的结点直到超出方阵。
不难发现其实这覆盖了整个方阵,故答案即为$n\times m\bmod p$
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| #include<algorithm> #include<iostream> #include<iomanip> #include<cstring> #include<cstdlib> #include<vector> #include<cstdio> #include<cmath> #include<queue> using namespace std; typedef long long LL; inline const LL Get_Int() { LL num=0,bj=1; char x=getchar(); while(x<'0'||x>'9') { if(x=='-')bj=-1; x=getchar(); } while(x>='0'&&x<='9') { num=num*10+x-'0'; x=getchar(); } return num*bj; } LL n,m,p; int main() { n=Get_Int(); m=Get_Int(); p=Get_Int(); printf("%lld\n",n*m%p); return 0; }
|