# 17 条题解

• @ 2017-12-22 14:56:29

《初等数论》第三版 83页定理4

设a1,a2及c均为正整数,gcd(a1,a2) = 1; 当 c >a1a2 - a1 - a2不定方程必有非负解。

证明原书很详细，略

定理5
设a1,a2及c均为正整数,gcd(a1,a2) = 1; 当 c > a1a2不定方程必有正解。

• @ 2017-11-12 17:51:43

woc，考试时打了八十多行！！！
#include<iostream>
using namespace std;
int main()
{
long long a,b,c;
cin>>a>>b;
c=a*b-a-b;
cout<<c;
return 0;
}

• @ 2018-01-29 21:55:12

Accepted

# 状态 耗时 内存占用

#1 Accepted 2ms 256.0 KiB
#2 Accepted 2ms 256.0 KiB
#3 Accepted 2ms 256.0 KiB
#4 Accepted 2ms 256.0 KiB
#5 Accepted 2ms 256.0 KiB
#6 Accepted 2ms 256.0 KiB
#7 Accepted 2ms 256.0 KiB
#8 Accepted 2ms 256.0 KiB
#9 Accepted 2ms 256.0 KiB
#10 Accepted 2ms 256.0 KiB
#11 Accepted 2ms 256.0 KiB
#12 Accepted 2ms 256.0 KiB
#13 Accepted 2ms 256.0 KiB
#14 Accepted 2ms 256.0 KiB
#15 Accepted 1ms 256.0 KiB
#16 Accepted 1ms 256.0 KiB
#17 Accepted 2ms 256.0 KiB
#18 Accepted 2ms 256.0 KiB
#19 Accepted 2ms 256.0 KiB
#20 Accepted 2ms 256.0 KiB
水题！RP 2000+ 纪念！
May The Father Of Understanding Guide U ！

• @ 2021-09-04 17:19:04

十年OI一场空，不开long long见祖宗。

``````#include <bits/stdc++.h>
using namespace std;

int main()
{
long long a,b;
cin>>a>>b;
cout<<a*b-a-b;
return 0;
}
``````
• @ 2018-03-23 01:40:46

不懂数论，纯找规律

``````#include <stdio.h>

int main()
{
int a, b;
scanf("%d%d", &a, &b);
printf("%lld", (long long)a * b - a - b);
}

``````
• @ 2018-02-06 10:26:36
``````#include<stdio.h>
int main(){
unsigned long long int a, b;
scanf("%lld%lld", &a, &b);
printf("%lld", a*b-(a+b));
return 0;
}
``````
• @ 2017-12-07 20:45:50

这题...呵呵

``````#include<bits/stdc++.h>
using namespace std;
int main(){
long long a,b;
scanf("%lld%lld",&a,&b);
printf("%lld",a*b-a-b);
return 0;
}
``````
• @ 2017-11-26 15:18:54

公式
#include <iostream>
using namespace std;
int main()
{
long long a,b;
cin>>a>>b;
cout<<a*b-a-b<<endl;
return 0;
}

• @ 2017-11-14 19:01:34

program lx;
var a,b,c:qword;
begin
c:=a*b-a-b;
write(c);
end.

• @ 2017-11-12 19:17:45

考试的时候写了半天暴力搜索
var i,j:int64;
begin
j:=(i-1)*(j-1)-1;
writeln(j);
end.

• @ 2018-10-12 21:35:22

#include<iostream>
using namespace std;long long n,m;int main(){cin >> n >> m;cout << (long long)n*m-m-n << endl;return 0;}

• @ 2017-11-13 17:33:28

打表找的规律，，。，，。没用**任何**数学证明！！！
详见我的blog: http://von-hyou.pub

``````#include <cstdio>
#include <cctype>
#include <algorithm>

typedef long long LL;

inline LL getInt() {
LL sum(0); char _c;
while (!isdigit(_c = getchar()));
do sum = sum * 10 + _c - '0';
while (isdigit(_c = getchar()));
return sum;
}

int main() {
LL n = getInt(), m = getInt();
if (n > m) std::swap(n, m);
if (n & 1 && m & 1)
printf("%lld\n", ((m >> 1) * (n >> 1) << 2) - 1);
else {
LL tmp = n & 1 ? n : m;
n = n & 1 ? m : n, m = tmp;
printf("%lld\n", (((n - 2) << 1) + 2) * (m >> 1) - 1);
} return 0;
}
``````
• @ 2017-11-13 10:34:36
``````#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <limits>
#include <string>
#include <sstream>
using namespace std;

const int oo_min=0xcfcfcfcf,oo_max=0x3f3f3f3f;

long long a,b;

int main()
{
while (~scanf("%lld%lld",&a,&b))
printf("%lld\n",a*b-a-b);
}
``````
• @ 2017-11-13 10:35:10

看出來的30s打完

• @ 2017-11-12 17:10:44

考试的时候 我居然用公式去验证我的暴力 还忘了longlong
#include <cstdio>
#include <iostream>
using namespace std;
long long int a,b;
int main()
{
cin>>a>>b;
cout<<a*b-a-b<<endl;
return 0;
}

• @ 2017-11-11 19:04:52
``````#include <iostream>
using namespace std;

long long a,b;
int main()
{
cin >>a>>b;
cout <<a*b-a-b<<endl;
}
``````
• @ 2017-11-11 18:53:20

#include <iostream>
#include <cstdlib>
#include <cstdio>

using namespace std;

long long a, b;
long long ret;
int main() {

cin >> a >> b;

ret = a* b - (a + b);
if (ret < 0) {
ret = 0;
}
cout << ret;
system("pause");
return 0;
}

• @ 2017-11-12 17:03:58

傻逼数学结论题，不想说啥了
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
using namespace std;
long long a,b;
long long ans;
{
char c;int ch=0,f=1;
while(c<'0'||c>'9')
{
if(c=='-')
f=-1;
c=getchar();
}
while(c>='0'&&c<='9')
{
ch=ch*10+c-'0';
c=getchar();
}
return ch*f;
}
int main()
{
ans=a*b-a-b;
printf("%lld\n",ans);
return 0;
}

• 1

ID
2028

2

(无)

962

430

45%

12