51,733
社区成员
发帖
与我相关
我的任务
分享第 1 题:排列字母
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
char str[50] = "WHERETHEREISAWILLTHEREISAWAY";
int main()
{
int len = strlen(str);
sort(str, str + len);
cout << str;
return 0;
}
#include <iostream>
using namespace std;
/* 由gcd(a, b) = gcd(a, b - a)得
gcd(a + k, b + k) = gcd(a + k, b- a)
令c = b - a, 则gcd(a + k, b - a) = gcd(a + k, c)
max(gcd(a + k, c)) = c
则a要增加多少就是c的倍数?
*/
int main()
{
long long a, b, c, res;
cin >> a >> b;
c = b - a;
res = c - a % c;
cout << res;
return 0;
}