# 3 条题解

• @ 2021-03-04 20:21:13

很简单，推理一下就行

``````#include<iostream>
using namespace std;
int main()
{
int n;scanf("%d",&n);
printf("%d",2*n-1);
return 0;
}
``````
• @ 2018-12-11 12:00:12
``````/*

*/
#define method_1
#ifdef method_1
/*
100分算法
答案显然是a=n-1且b=n
*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long ll;
const int maxn=+5;
const ll INF=0x3f3f3f3f3f3f3f3fll;

int main() {
ios::sync_with_stdio(false);
freopen("偷拍硕哥2.in","r",stdin);
int n;
cin>>n;
cout<<2*n-1;

return 0;
}
#endif
#ifdef method_2
/*
50分算法
*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long ll;
const int maxn=1000+5;
const ll INF=0x3f3f3f3f3f3f3f3fll;
int gcd(int a,int b){
return !b?a:gcd(b,a%b);
}
int main() {
ios::sync_with_stdio(false);
freopen("偷拍硕哥2.in","r",stdin);
int n;
cin>>n;
int ans=0;
for(int i=n;i>=1;i--){
for(int j=n;j>=1;j--){
if(gcd(i,j)==1){
ans=max(i+j,ans);
}
}
}
cout<<ans;
return 0;
}
#endif
#ifdef method_3
/*

*/

#endif

``````
• @ 2021-01-17 10:27:53

/*

/
#define method_1
#ifdef method_1
/

100分算法
答案显然是a=n-1且b=n
*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long ll;
const int maxn=+5;
const ll INF=0x3f3f3f3f3f3f3f3fll;

int main() {
ios::sync_with_stdio(false);
freopen("偷拍硕哥2.in","r",stdin);
int n;
cin>>n;
cout<<2*n-1;

return 0;
}
#endif
#ifdef method_2
/*
50分算法
/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long ll;
const int maxn=1000+5;
const ll INF=0x3f3f3f3f3f3f3f3fll;
int gcd(int a,int b){
return !b?a:gcd(b,a%b);
}
int main() {
ios::sync_with_stdio(false);
freopen("偷拍硕哥2.in","r",stdin);
int n;
cin>>n;
int ans=0;
for(int i=n;i>=1;i--){
for(int j=n;j>=1;j--){
if(gcd(i,j)==1){
ans=max(i+j,ans);
}
}
}
cout<<ans;
return 0;
}
#endif
#ifdef method_3
/

*/

#endif

• 1

5

(无)

(无)

213

80

38%

6