HDU 1999 不可摸数 (水题)

【题意简述】:中文题

【分析】:想法很简单,因为n的范围仅仅是  2<= n<=1000,所以根据题目描述,我只需要打出一个表即可解决问题,表里存放每一个S(i)的值,如果输入的n能与表中的值相对应,就不是不可摸数,相反便是不可摸数!

不过要注意这里边表的那个上线,我们可以试出来,最后我测试出的结果是5000左右。

#include<iostream>
using namespace std;

int a[5000]={0};

int main()
{
    int n,i,j,m,flag=0;
    a[0]=1;a[1]=1;
    for(i=2;i<5000;i++)
    {
    	a[i]=0;
     	for(j=1;j<=i/2;j++)
      	if(i%j==0)
       	a[i]+=j;
    }
    cin>>n;
    while(n--)
    {
       	cin>>m;
       	for(i=0;i<=1000;i++)
       	{
   			if(m==a[i])
      		{
        		flag=1;
          		break;
            }
        }
        if(flag==0)
        	cout<<"yes"<<endl;
        else
        	cout<<"no"<<endl;
    }
    return 0;
}
时间: 2024-08-12 19:40:13

HDU 1999 不可摸数 (水题)的相关文章

hdu 1999 不可摸数 水题。

不可摸数 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7966    Accepted Submission(s): 2024 Problem Description s(n)是正整数n的真因子之和,即小于n且整除n的因子和.例如s(12)=1+2+3+4+6=16.如果任何数m,s(m)都不等于n,则称n为不可摸数. Input 包

HDU 1999 不可摸数

/* 中文题意: 中文翻译: 题目大意:见红字(如下) 解题思路:打表,将每个数的合数之和存在一个数组之中 难点详解:用两个for循环写的,第二个for循环主要是解释两个数相乘不超过这个最大数的上限,下面的a[i*j]主要是用来记录合数之和,同时也保证了数组上限在最大值里面 关键点:求在1000以内合数之和,打表 解题人:lingnichong 解题时间:2014/7/31    17:52 解题感受:一开始错了几次,原因是数组开小了,后台数组很大,他又说对任意的m,所以数组要开很大才会满足题意

hdu 1999 不可摸数 筛选素数 两次打表

不可摸数 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8590    Accepted Submission(s): 2242 Problem Description s(n)是正整数n的真因子之和.即小于n且整除n的因子和.比如s(12)=1+2+3+4+6=16.假设不论什么 数m,s(m)都不等于n,则称n为不可摸数. Inp

HDU 5590 ZYB&#39;s Biology 水题

ZYB's Biology Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5590 Description ZYB(ZJ−267)在NOIP拿到600分之后开始虐生物题,他现在扔给你一道简单的生物题:给出一个DNA序列和一个RNA序列,问它们是否配对. DNA序列是仅由A,C,G,T组成的字符串,RNA序列是仅由A,C,G,U组成的字符串. DNA和RNA匹配当且仅当每

hdoj 1999 不可摸数 【数学】

题意:... 简单来说,就是要找出50万以内的数的真因子之和,再做个标记 代码: #include <stdio.h> #include <string.h> #define M 500000 int a[M]; int ok[M]; void f() { int i, j; for(i = 1; i < M; i ++){ for(j = 1; j*i < M; j ++){ a[i*j]+=i; } } for(i = 1; i < M; i ++){ a[i

HDU Senior&#39;s Gun (水题)

题意:给n把枪,m个怪兽,每把枪可消灭1怪兽,并获得能量=枪的攻击力-怪兽的防御力.求如何射杀能获得最多能量?(不必杀光) 思路:用最大攻击力的枪杀防御力最小的怪兽明显可获得最大能量.如果每把枪都去射杀刚好1点能量都拿不到的怪物,那简直等于把枪全丢掉. 1 //#pragma comment(linker,"/STACK:102400000,102400000") 2 #include <iostream> 3 #include <stdio.h> 4 #inc

hdu 4847 Wow! Such Doge! 水题

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4847 统计文本中一共有多少个“Doge” 水题 #include <cstring> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #include <iostream> #include <cstdio> #includ

POJ 2239--Selecting Courses【二分图 &amp;&amp; 最大匹配数 &amp;&amp; 水题】

Selecting Courses Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9363   Accepted: 4164 Description It is well known that it is not easy to select courses in the college, for there is usually conflict among the time of the courses. Li Mi

HDU 5578 Friendship of Frog 水题

Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5578 Description N frogs from different countries are standing in a line. Each country is represented by a lowercase letter. The distance betwee