#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, a = 0, t;
scanf("%d%d", &n, &m);
t = m / 2;
for (int a = 1; a <= t; a++) {
if (N % a == 0 && (N % (M - a) == 0)) {
t = -1;
break;
}
}
if (t != -1)
printf("-1");
else
printf("%d", a);
return 0;
}
编译信息
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:9:6: error: 'N' was not declared in this scope
9 | if(N%a==0 && (N%(M-a)==0)) { t=-1; break; }
| ^
/sandbox/1/a.cpp:9:20: error: 'M' was not declared in this scope
9 | if(N%a==0 && (N%(M-a)==0)) { t=-1; break; }
| ^
/sandbox/1/a.cpp:5:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
5 | scanf("%d%d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~
共 7 条回复
n,m都是小写的,你后面写了大写N,M
...好的
再发一次
感谢大佬
哪道题
请在代码前用```cpp