传送门

【传送门】

题目大意

求\(\frac{1}{x}+\frac{1}{y}=\frac{1}{n}\)有多少组不同的解。

分析

将式子转化成\((n-x)(n-y)=n^2\)的形式。
那么很明显,因为我们要求正整数的解,那么就是要求\(a\times b=n^2\)的解的个数。
又变成了约数个数的问题。

代码

#include <bits/stdc++.h>
#define ll long long
#define ms(a, b) memset(a, b, sizeof(a))
#define inf 0x3f3f3f3f
#define db double
using namespace std;
template <typename T>
inline void read(T &x) {
    x = 0; T fl = 1; char ch = 0;
    for (; ch < '0' || ch > '9'; ch = getchar())
        if (ch == '-') fl = -1;
    for (; ch >= '0' && ch <= '9'; ch = getchar())
        x = (x << 1) + (x << 3) + (ch ^ 48);
    x *= fl;
}
ll n, ans;
int main() {
    read(n); ans = 1;
    for (ll i = 2; i * i <= n; i ++) {
        if (n % i == 0) {
            ll tot = 0;
            for (; n % i == 0; n /= i) ++ tot;
            ans *= (tot * 2 + 1);
        }
    }
    if (n > 1) ans *= 3;
    printf("%lld\n", (ans + 1) / 2);
    return 0;
}

[luogu5253]丢番图【数学】的更多相关文章

  1. bzoj 4459: [Jsoi2013]丢番图 -- 数学

    4459: [Jsoi2013]丢番图 Time Limit: 10 Sec  Memory Limit: 64 MB Description 丢番图是亚历山大时期埃及著名的数学家.他是最早研究整数系 ...

  2. BZOJ 4459: [Jsoi2013]丢番图 数学推导

    之前绝对做过几乎一模一样的题,现在做竟然忘了. code: #include <bits/stdc++.h> #define ll long long #define setIO(s) f ...

  3. BZOJ_4459_[Jsoi2013]丢番图_数学+分解质因数

    BZOJ_4459_[Jsoi2013]丢番图_数学+分解质因数 Description 丢番图是亚历山大时期埃及著名的数学家.他是最早研究整数系数不定方程的数学家之一. 为了纪念他,这些方程一般被称 ...

  4. Project Euler 110:Diophantine reciprocals II 丢番图倒数II

    Diophantine reciprocals II In the following equation x, y, and n are positive integers. For n = 4 th ...

  5. Project Euler 108:Diophantine reciprocals I 丢番图倒数I

    Diophantine reciprocals I In the following equation x, y, and n are positive integers. For n = 4 the ...

  6. 【bzoj4459】[Jsoi2013]丢番图 分解质因数

    题目描述 丢番图是亚历山大时期埃及著名的数学家.他是最早研究整数系数不定方程的数学家之一.为了纪念他,这些方程一般被称作丢番图方程.最著名的丢番图方程之一是x^N+y^n=z^N.费马提出,对于N&g ...

  7. bzoj4459[Jsoi2013]丢番图

    bzoj4459[Jsoi2013]丢番图 题意: 丢番图方程:1/x+1/y=1/n(x,y,n∈N+) ,给定n,求出关于n的丢番图方程有多少组解.n≤10^14. 题解: 通分得yn+xn=xy ...

  8. 【bzoj4459】JSOI2013丢番图

    某JSOI夏令营出题人啊,naive! 你还是得学习个,搬这种原题不得被我一眼看穿? 求个n^2的约数除以二,向上取整. #include<bits/stdc++.h> using nam ...

  9. Codeforces Round #368 (Div. 2)A B C 水 图 数学

    A. Brain's Photos time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

随机推荐

  1. stark组件之pop页面,按钮,url,页面

      1.Window open() 方法 2.admin的pop添加按钮 3.stark之pop功能 3.知识点总结 4.coding代码 1.Window open() 方法 效果图   2.adm ...

  2. IntelliJ IDEA/WebStrom破解及JDK配置

    title: IntelliJ IDEA/WebStrom破解及JDK配置 (一)破解 破解步骤 第一步:下载破解补丁 第二步:修改配置文件 第三步:重启IntelliJ IDEA/WebStrom填 ...

  3. Drools 规则引擎

    Drools - Drools - Business Rules Management System (Java™, Open Source) http://drools.org/ [Drools]J ...

  4. checkbox的使用总结,判断是否选中

    方法一: if ($("#checkbox-id").get(0).checked) { // do something } 方法二: if($('#checkbox-id').i ...

  5. C#设计模式之3:观察者模式

    C#中已经实现了观察者模式,那就是事件,事件封装了委托,使得委托的封装性更好,在类的内部定义事件,然后在客户端对事件进行注册: public class Subject { public event ...

  6. Flutter之 LimitedBox、Offstage、OverflowBox、SizedBox详解

    1. LimitedBox A box that limits its size only when it's unconstrained. 1.1 简介 LimitedBox,通过字面意思,也可以猜 ...

  7. python爬虫scrapy之rules的基本使用

    Link Extractors Link Extractors 是那些目的仅仅是从网页(scrapy.http.Response 对象)中抽取最终将会被follow链接的对象。 Scrapy默认提供2 ...

  8. python之路--小数据池,再谈编码,is和 == 的区别

    一 . 小数据池 # 小数据池针对的是: int, str, bool 在py文件中几乎所有的字符串都会缓存. # id() 查看变量的内存地址 s = 'attila' print(id(s)) 二 ...

  9. 让PC端页面在手机端显示缩小版的解决方法

    做页面的时候我们做好pC端页面时,因编辑那边需求,在手机端页面也应该是缩小版,不能乱的.在网上找了各种解决方案,经实验,这种是可以的: 在head里边加上这两句meta  <meta name= ...

  10. vs code軟件操作

    https://www.imooc.com/article/39349 https://www.html.cn/archives/8144