题目传送门 /* x>=y, 1/x <= 1/y, 因此1/k - 1/y <= 1/y, 即y <= 2*k */ #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include <string> #include <map> #include <…
10976 Fractions Again It is easy to see that for every fraction in the form 1 k (k > 0), we can always find two positive integers x and y, x ≥ y, such that: 1 k = 1 x + 1 y Now our question is: can you write a program that counts how many such pairs…
直接暴力 没技巧 y应该从k+1开始循环,因为不然y-k<0的时候 你相当于(x*y) % (负数) 了. #include <iostream> using namespace std; ]; ]; int main() { int k,cnt; while(cin>>k) { cnt=; ;y<=*k;y++) { ) ) { X[cnt]=k*y/(y-k); Y[cnt]=y; cnt++; } } cout<<cnt<<endl; ;i…
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAB3gAAAM+CAIAAAB31EfqAAAgAElEQVR4nOzdO7KtPJum69GEpAcVQQfSoA80ATddvDLSogMV9ICINLaJkUZZ2NvAKGtH4FcQZaZR9IFtvP96fy0OQkgCxuG+rO9bc86BACGJBw3xmgEAAAAAAAAAcPD/7Xg9XTAAAAAAAAAAwGcgaAYAAAAAAAAABCFoBgAAAAAAAAAEIWgGAAAAA…
[题意]:给你一个数k,求所有使得1/k = 1/x + 1/y成立的x≥y的整数对. [分析]:枚举所有在区间[k+1, 2k]上的 y 即可,当 1/k - 1/y 的结果分子为1即为一组解. [代码]: #include<bits/stdc++.h> using namespace std; int x[10005]; int y[10005]; #define LL long long int main() { int k,c; while(~scanf("%d",…
UVA.10986 Fractions Again (经典暴力) 题意分析 同样只枚举1个,根据条件算出另外一个. 代码总览 #include <iostream> #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <sstream> #include <set> #include <map&g…
UVA 725 题意:0~9十个数组成两个5位数(或0开头的四位数),要求两数之商等于输入的数据n.abcde/fghij=n. 思路:暴力枚举,枚举fghij的情况算出abcde判断是否符合题目条件.(注意前导零的判断) 枚举的方法为 for(int i=1234;i<=100000/n;i++){}  #include<cstdio> #include<cstring> ]; bool check(int a,int b) { memset(num,,sizeof num…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] x>=y => \(\frac{1}{x}<=\frac{1}{y}\) => \(\frac{1}{x}=\frac{1}{k}-\frac{1}{y}\) 结合两个式子可以得到 y<=2*k 则枚举y,然后根据式子得到x,判断合法性就ok [代码] /* 1.Shoud it use long long ? 2.Have you ever test several sample(at least ther…
It is easy to see that for every fraction in the form  (k > 0), we can always find two positive integers x and y,x ≥ y, such that: . Now our question is: can you write a program that counts how many such pairs of x and y there are for any givenk? Inp…
题目链接:https://vjudge.net/problem/UVA-10976 It is easy to see that for every fraction in the form 1k(k > 0), we can always find two positive integers x and y, x ≥ y, such that: 1/k=1/x+1/y Now our question is: can you write a program that counts how ma…