版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u011328934/article/details/36409469 option=com_onlinejudge&Itemid=8&page=show_problem&category=474&problem=2828&mosmsg=Submission+received+with+ID+13820744" rel="nofollow"…
Uva 11728 - Alternate Task 题目链接 题意:给定一个因子和.求出相应是哪个数字 思路:数字不可能大于因子和,对于每一个数字去算出因子和,然后记录下来就可以 代码: #include <stdio.h> #include <string.h> const int N = 1005; int n, ans[N]; void init() { memset(ans, -1, sizeof(ans)); for (int i = 1; i <= 1000;…
vjudge 上题目链接:uva 11728 其实是个数论水题,直接打表就行: #include<cstdio> #include<algorithm> using namespace std; ]; inline ) { ; i <= n; ++i) { ; ; j <= i; ++j) ) sum += j; ) ans[sum] = i; } } int main() { ; init(); while(~scanf("%d",&s),…
题目链接 题意:给出一个数S,求一个最大的数,使这个数所有的因子之和为S; 这个所谓“因子之和”不知道有没有误导性,因为一开始以为得是素数才行.后来复习了下小学数学,比如12的因子分别是1,2,3,4,6,12... 我竟无言以对T^T... 感觉复杂度应该能继续优化的..没想到好的.. 代码: #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include&l…
Little Hasan loves to play number games with his friends. One day they were playing a game whereone of them will speak out a positive number and the others have to tell the sum of its factors. Thefirst one to say it correctly wins. After a while they…
题意:给定一个 n,求一个最大正整数 N 使得 N 的所有正因数和等于 n. 析:对于任何数一个 n,它的所有正因子都是大于等于本身的,因为 n 本身就是自己的正因数,这样的就可以直接暴力了,答案肯定是在 1 ~ n 范围内. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib&…
  Three Families  Three families share a garden. They usually clean the garden together at the end of each week, but last week, family C was on holiday, so family A spent 5 hours, family B spent 4 hours and had everything done. After coming back, fam…
The first place of 2^n Problem Description LMY and YY are mathematics and number theory lovers. They like to find and solve interesting mathematic problems together. One day LMY calculates 2n one by one, n=0, 1, 2,- and writes the results on a sheet…
There is a war and it doesn't look very promising for your country. Now it's time to act. You have a commando squad at your disposal and planning an ambush on an important enemy camp located nearby. You have N soldiers in your squad. In your master-p…
http://poj.org/problem?id=1061 傻逼题不多说 (x+km) - (y+kn) = dL 求k 令b = n-m ; a = x - y ; 化成模线性方程一般式 : Lx+by=a 再除gcd化简成最简形式 使得L,b互素 (即构造 L'x+b'y =1) 求Ex_GCD得到 y * a 就是最后的答案...还是一样要化成正整数形式 pair<LL,LL> ex_gcd(LL a,LL b){ ) ,); pair<LL,LL> t = ex_gcd(…