[HDU5970] 最大公约数
题目
原题地址
解说
我承认看了半天真不会只会暴力,看的题解,结果第一篇题解带的代码还T了还得再看一篇。
直接参阅此博客,讲解比较详细但是提供的代码是\(T\)的。
代码可以参阅。
代码
#include
using namespace std;
typedef long long ll;
const int maxn = 700;
int gcd[maxn][maxn],num[maxn][maxn];
int n,m,p;
ll calc(ll x,ll y,ll tot,ll cnt){
ll ans = (tot+1)*(x*y)+(tot+1)*tot/2*(y*y);
ll rd = y*y%cnt;
ll ra = y*x%cnt;
ll res = 0;
for(int i=0;i
幸甚至哉,歌以咏志。