Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) A. Fraction
题意:2个数A,B,A+B==n,并且A<B,问最大的A/B是多少,A与B互质
1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=1e5+100; 4 typedef long long ll; 5 6 7 int main(){ 8 int n; 9 cin>>n; 10 for(int i=n/2;i>=1;i--){ 11 int y=n-i; 12 if(__gcd(i,y)==1){ 13 cout<<i<<" "<<y<<endl;return 0; 14 } 15 } 16 }