2 条题解

  • 0
    @ 2025-10-8 17:00:02
    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    LL gcd(LL x, LL y) {if(x==0) return y; else return gcd(y%x, x);}
    int main(){
        //freopen("a.in", "r", stdin);
        int T; scanf("%d", &T);
        while(T--){
            LL n, m, ans=0; scanf("%lld%lld", &n, &m);
            for(LL i=1; i<=n/i; i++) for(LL j=1; j<=m/j; j++)
                if(gcd(i, j)==1) ans+=min(n/i, m/j)/(i+j);
            printf("%lld\n", ans);
        }
        return 0;
    }
    
    • 0
      @ 2025-10-8 16:59:54
      #include<bits/stdc++.h>
      using namespace std;
      typedef long long LL;
      LL gcd(LL x, LL y) {if(x==0) return y; else return gcd(y%x, x);}
      int main(){
          //freopen("a.in", "r", stdin);
          int T; scanf("%d", &T);
          while(T--){
              LL n, m, ans=0; scanf("%lld%lld", &n, &m);
              for(LL i=1; i<=n/i; i++) for(LL j=1; j<=m/j; j++)
                  if(gcd(i, j)==1) ans+=min(n/i, m/j)/(i+j);
              printf("%lld\n", ans);
          }
          return 0;
      }
      • 1

      信息

      ID
      2118
      时间
      1500ms
      内存
      256MiB
      难度
      8
      标签
      递交数
      22
      已通过
      5
      上传者