UVa 11728 Alternate Task (枚举)】的更多相关文章

题意:给定一个 n,求一个最大正整数 N 使得 N 的所有正因数和等于 n. 析:对于任何数一个 n,它的所有正因子都是大于等于本身的,因为 n 本身就是自己的正因数,这样的就可以直接暴力了,答案肯定是在 1 ~ n 范围内. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib&…
版权声明:本文为博主原创文章,未经博主同意不得转载. 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),…
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…
题目链接 题意:给出一个数S,求一个最大的数,使这个数所有的因子之和为S; 这个所谓“因子之和”不知道有没有误导性,因为一开始以为得是素数才行.后来复习了下小学数学,比如12的因子分别是1,2,3,4,6,12... 我竟无言以对T^T... 感觉复杂度应该能继续优化的..没想到好的.. 代码: #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include&l…
题意: 输入一个正整数S,(S  <= 1000)求一个最大的正整数N,使得N的所有正因子之和为S. 解析: ..求1000以内的所有数的正因子和 ...输出.. #include <iostream> #include <cstdio> #include <sstream> #include <cstring> #include <map> #include <set> #include <vector> #inc…
10465 - Homer Simpson Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=114&page=show_problem&problem=1406 这数据量..枚举绝对是最快的方式了. 完整代码: /*0.025s*/ #include<bits/stdc++.h> using namesp…
Password Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVA. Original ID: 1262 64-bit integer IO format: %lld      Java class name: Main pid=18400" class="btn" style="">Prev Submit showpid=18401"…
题目大意:有3个整数 x[1], a, b 满足递推式x[i]=(a*x[i-1]+b)mod 10001.由这个递推式计算出了长度为2T的数列,现在要求输入x[1],x[3],......x[2T-1], 输出x[2],x[4]......x[2T]. T<=100,0<=x<=10000. 如果有多种可能的输出,任意输出一个结果即可. 由于a和b都小于等于10000,直接枚举a和b暴力可以过.但是有没有更快的方法呢? 首先令递推式的i=2,那么x[2]=(a*x[1]+b)mod 1…