当前位置:网站首页>[code source] score split of one question per day
[code source] score split of one question per day
2022-07-25 09:37:00 【self_ disc】
Topic link : Fraction split - subject - Daimayuan Online Judge
Title Description :
Enter a positive integer k, Find all positive integers y≤x, bring 1/k=1/x+1/y.
Input format
Enter a positive integer k(1≤k≤10^7).
Output format
Output a number , That satisfies the condition x,y The number of .
The sample input
12Sample output
8because k The scope is very large, corresponding to x,y The value may also be very large , If violence enumeration will undoubtedly timeout , Then let's consider narrowing the scope of enumeration .
given k,x,y The relationship between ,k It is known that , Yes x,y When we know one term, we can push it to another term by equation . According to y<=x, You can get y<=2k, also y>k. From the equation, we can get x=(ky)/(y-k).
Code :
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll cnt, k, ans;
int main()
{
cin >> k;
for (ll y = k + 1; y <= k + k; y++)
{
if ((k * y) % (y - k) == 0)
ans++;
}
cout << ans;
}边栏推荐
猜你喜欢
随机推荐
*6-2 CCF 2015-03-3 节日
How to customize the title content of uni app applet (how to solve the problem that the title of applet is not centered)
[gplt] 2022 popular lover (Floyd)
Redis list structure command
¥1-2 例2.2 将两个集合的并集放到线性表中
Flutter Rive 多状态例子
laravel 调用第三方 发送邮件 (php)
C language and SQL Server database technology
How many regions can a positive odd polygon be divided into
作业7.21 约瑟夫环问题与进制转换
Basic network knowledge
## 使用 Kotlin USE 简化文件读写
App的生命周期和AppleDelegate,SceneDelegate
Swagger2显示get接口有问题,加注解就能解决
Object initialization
How to obtain location information (longitude and latitude) by uni app
作业7.19 顺序表
@1-1 CCF 2021-04-1 灰度直方图
Week小结
Swagger2 shows that there is a problem with the get interface, which can be solved with annotations








