2 solutions

  • 0
    @ 2026-8-27 15:51:38
    #include<bits/stdc++.h>
    using namespace std;
    int A,B,l;
    double get(int a,int b){
    	return a*1.0/b;
    }
    int main(){
    	cin>>A>>B>>l;
    	int a=l,b=1;
    	for(int i=1;i<=l;i++){
    		for(int j=1;j<=l;j++){
    			if(get(i,j)>=get(A,B)&&get(a,b)>get(i,j))a=i,b=j;
    		}
    	}
    	cout<<a<<' '<<b;
    }
    
    • -1
      @ 2024-6-12 10:39:26

      枚举(L2L^2)

      • 分别枚举分子和分母,然后尝试去更新答案。
      #include<bits/stdc++.h>
      using namespace std;
      double get(int a,int b)
      {
          return a*1.0/b;
      }
      int main()
      {
          int A,B,L;
          cin>>A>>B>>L;
          int a=L,b=1;
          for(int i=1;i<=L;i++) //枚举分子
          {
              for(int j=1;j<=L;j++) //枚举分母
              {
                  if(get(i,j)>=get(A,B)&&get(a,b)>get(i,j)) //当前枚举的数介于A/B 到答案之间
                  {
                      a=i,b=j;
                  }
              }
          }
          cout<<a<<" "<<b;
          return 0;
      }
      
      • 1

      Information

      ID
      462
      Time
      1000ms
      Memory
      128MiB
      Difficulty
      6
      Tags
      # Submissions
      28
      Accepted
      11
      Uploaded By