HDU 1999 不可摸数【类似筛法求真因子和】
不可摸数
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 15591 Accepted Submission(s): 4077
数m,s(m)都不等于n,则称n为不可摸数.
2
5
8
yes
no
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<set>
#include<map>
#include<sstream>
#include<queue>
#include<cmath>
#include<list>
#include<vector>
#include<string>
using namespace std;
#define long long ll
const double PI = acos(-1.0);
const double eps = 1e-;
const int inf = 0x3f3f3f3f;
const int N = ;
int n, m, tot;
int a[]={};
int r[], c[];
int x, y, pr, pc;
int ok(int n)
{
int sum = ;
for(int i= ;i<n; i++)
{
if(n % i == )
{
sum += i;
}
}
return sum;
} int main()
{ int t, f = ;
cin >> t;
while(t--)
{
//f = 0;
cin >> n;
int i = ;
while(i++ <= )
{
if(ok(i) == n)
{
f = ; break;
}
}
printf("%s\n",f?"no":"yes");
}
return ;
}
蒻数据下的无趣暴力
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<set>
#include<map>
#include<sstream>
#include<queue>
#include<cmath>
#include<list>
#include<vector>
#include<string>
using namespace std;
#define long long ll
const double PI = acos(-1.0);
const double eps = 1e-;
const int inf = 0x3f3f3f3f;
const int N = ;
int n, m, tot;
int a[N];
int mp[N];
int x, y, pr, pc; void init()
{
for(int i=; i<=N; i++)
{
for(int j=i+i; j<=N; j+=i)
{
a[j] += i;
}
}
for(int j=; j<=N; j++)
{
if(a[j] <= ) mp[a[j]] = ; //hash标记
}
} int main()
{ int t;
cin >> t;
init();
while(t--)
{
cin >> n;
printf("%s\n",mp[n]?"no":"yes");
}
return ;
}
筛法思想-31MS-ojbk
HDU 1999 不可摸数【类似筛法求真因子和】的更多相关文章
- HDU - 1999 不可摸数,快速求因子和
题意:定义s[m]为m内的因子的和,给定一个n,判断是否有s[m]==n,若没有,则是不可摸数. 思路:首先要打表求出s[m]的值,标记这些出现过的值. 打表求因子和: for(int i=1;i&l ...
- hdu 1999 不可摸数 水题。
不可摸数 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- HDU 1999 不可摸数
/* 中文题意: 中文翻译: 题目大意:见红字(例如以下) 解题思路:打表,将每一个数的合数之和存在一个数组之中 难点具体解释:用两个for循环写的,第二个for循环主要是解释两个数相乘不超过这个最大 ...
- hdu 1999 不可摸数 筛选素数 两次打表
不可摸数 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- HDU 1999 不可摸数 (模拟)
题目链接 Problem Description s(n)是正整数n的真因子之和,即小于n且整除n的因子和.例如s(12)=1+2+3+4+6=16.如果任何数m,s(m)都不等于n,则称n为不可摸数 ...
- 不可摸数 【杭电-HDOJ-1999】 附题
/* hdu 1999 不可摸数 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDU 1565 - 方格取数(1) - [状压DP][网络流 - 最大点权独立集和最小点权覆盖集]
题目链接:https://cn.vjudge.net/problem/HDU-1565 Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32 ...
- 2015 HDU 多校联赛 5317 RGCDQ 筛法求解
2015 HDU 多校联赛 5317 RGCDQ 筛法求解 题目 http://acm.hdu.edu.cn/showproblem.php? pid=5317 本题的数据量非常大,測试样例多.数据 ...
- HDOJ-1999 不可摸数
不可摸数 转自:http://www.cnblogs.com/dongsheng/archive/2012/08/18/2645594.html Time Limit: 2000/1000 MS (J ...
随机推荐
- [Uva1642]魔法Gcd(数论)
Description 给定n个数,某个连续区间[L,R]的收益为\(gcd(A_l,A_{l+1},A_{l+2}...A_r)*(r-l+1)\), 求收益最大的区间的收益值 \(1 \leq n ...
- Linux命令之---ls
命令简介: ls(list)命令用来列出目标目录(缺省的话为当前目录)中所有的子目录和文件. 指令所在路径:/bin/ls 执行权限:All User 命令语法: ls [选项] [目录名] 命令参数 ...
- 在F12 控制台输入,可执行jquery操作
<!-- 控制台执行jquery -->var importJs=document.createElement('script') //在页面新建一个script标签importJs.se ...
- 洛谷P1553数字反转升级版
题目链接:https://www.luogu.org/problemnew/show/P1553
- MySQL基础4-SQL简单查询(单表)
1.SELECT语句 2.运算符的优先级 利用Navicat中的查询方法: 栗子1:查询所有货品信息 栗子2:查询所有货品的id,productName,salePrice 当查询错误的时候出现的界面 ...
- 微信SSL证书更换的检查与安装方法
Ubuntu, Debian 查看根证书 确认操作系统上,是否存在以下文件: /etc/ssl/certs/DigiCert_Global_Root_CA.pem /etc/ssl/certs/Bal ...
- logback mybatis 打印sql语句
logbac.xml 文件的基础配置参考的园友的 http://www.cnblogs.com/yuanermen/archive/2012/02/13/2349609.html 然后hibernat ...
- laravel5.2总结--数据库操作
1 配置信息 1.1配置目录: config/database.php 1.2配置多个数据库 //默认的数据库 'mysql' => [ 'driver' => 'mysql', 'hos ...
- LeetCode with Python -> String
344. Reverse String Write a function that takes a string as input and returns the string reversed. E ...
- 收藏网址 jquery学习
http://www.zhangxinxu.com/wordpress/2009/08/jquery-%E5%8D%95%E5%87%BB%E6%96%87%E5%AD%97%E6%88%96%E5% ...