zoukankan      html  css  js  c++  java
  • 等式

    求 1/a + 1/b = 1/n的正数解

    设 x = a + n, y = b + n, 原式变为 a * b = n * n

    答案微n * n 的约数个数加一之后的一半, 因为n * n 太大不能直接求因子个数需要通过质因子个数求约数个数。

     1 #include<bits/stdc++.h>
     2 #define LL long long
     3 #define fi first
     4 #define se second
     5 #define mk make_pair
     6 #define pii pair<int,int>
     7 using namespace std;
     8 
     9 const int N = 1000 + 7;
    10 const int M = 100 + 7;
    11 const int inf = 0x3f3f3f3f;
    12 const LL INF = 0x3f3f3f3f3f3f3f3f;
    13 const int mod = 1e9 + 7;
    14 
    15 
    16 LL n, cnt[100], tot;
    17 
    18 int main() {
    19     int T; scanf("%d", &T);
    20     while(T--) {
    21         tot = 0;
    22         memset(cnt, 0, sizeof(cnt));
    23         scanf("%lld", &n);
    24         for(int i = 2; i * i <= n; i++) {
    25             if(n % i == 0) {
    26                 while(n % i == 0)
    27                     cnt[tot]++, n /= i;
    28                 tot++;
    29             }
    30         }
    31         if(n != 1)
    32             cnt[tot]++, tot++;
    33 
    34         for(int i = 0; i < tot; i++)
    35             cnt[i] *= 2;
    36         LL ans = 1;
    37         for(int i = 0; i < tot; i++)
    38             ans *= cnt[i] + 1;
    39         printf("%lld
    ", (ans + 1) / 2);
    40     }
    41     return 0;
    42 }
    43 
    44 /*
    45 */
  • 相关阅读:
    模仿jquery框架源码 -成熟---选择器
    模仿jquery框架源码---网络
    jquery链式语法
    jquery跟DOM转换
    jquery选择器
    基本jquery
    滚屏加载--无刷新动态加载数据技术的应用
    CenterFactory
    IImage--factory
    redis的使用及方法
  • 原文地址:https://www.cnblogs.com/CJLHY/p/8808756.html
Copyright © 2011-2022 走看看