【题目链接】
【算法】
gcd(a,a+1) = 1
所以当a = b时,答案为a,否则为1
【代码】
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main() {
cin >> a >> b;
if (a == b) cout<< a << endl;
else cout<< 1 << endl;
return 0;
}
本文介绍了一个简单的算法问题:求两个连续整数的最大公约数总是1,特殊情况除外。通过判断输入的两个字符串是否相等来决定输出结果。
【题目链接】
【算法】
gcd(a,a+1) = 1
所以当a = b时,答案为a,否则为1
【代码】
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main() {
cin >> a >> b;
if (a == b) cout<< a << endl;
else cout<< 1 << endl;
return 0;
}
293
1394

被折叠的 条评论
为什么被折叠?