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 ...
随机推荐
- Codeforces Round #461 (Div. 2) C. Cave Painting
C. Cave Painting time limit per test 1 second memory limit per test 256 megabytes Problem Descriptio ...
- WEBs
http://www.cnblogs.com/wupeiqi/articles/5341480.html 请求方式8种: 1.GET:请求指定页面信息,并返回实体 2.POST:向指定资源提交数据进行 ...
- 9、JS对象 知识总结
1.对象 <!DOCTYPE html> <html> <body> <script> <!-- 新建对象 --> person=new O ...
- 【SCOI 2010】股票交易
题目 最近 \(\text{lxhgww}\) 又迷上了投资股票,通过一段时间的观察和学习,他总结出了股票行情的一些规律. 通过一段时间的观察,\(\text{lxhgww}\) 预测到了未来 \(T ...
- MFC深入浅出读书笔记第一部分
最近看侯捷的MFC深入浅出,简单总结一下. 第一章首先就是先了解一下windows程序设计的基础知识,包括win32程序开发基础,什么*.lib,*.h,*.cpp的,程序入口点WinMain函数,窗 ...
- sqlserver不能创建数据库关系图
use [你的数据库名]EXEC sp_changedbowner 'sa'
- springboot集成pagehelper插件
1.在pom.xml中引入依赖 <dependency> <groupId>com.github.pagehelper</groupId> <artifact ...
- ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: Incompatible namespaceIDs
用三台centos操作系统的机器搭建了一个hadoop的分布式集群.启动服务后失败,查看datanode的日志,提示错误:ERROR org.apache.hadoop.hdfs.server.dat ...
- 微信小程序--问题汇总及详解之清空电话号码
wxml: <view class="btns" wx:for="{{phoneList}}" wx:key="id"> < ...
- 理解点击屏幕的事件响应--->对- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event方法的理解
要理解这两个方法.先了解一下用户触摸屏幕后的事件传递过程. 当用户点击屏幕后,UIApplication 先响应事件,然后传递给UIWindow.如果window可以响应.就开始遍历window的su ...