hdu 5150(水题)
Sum Sum Sum
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1033 Accepted Submission(s): 612
Now you are given a sequence of integers. You task is to calculate the sum of P-numbers of the sequence.
In each test case:
The first line contains a integer N(1≤N≤1000). The second line contains N integers. Each integer is between 1 and 1000.
5 6 7
1
10
0
- #include<stdio.h>
- #include<iostream>
- #include<string.h>
- #include <stdlib.h>
- #include<math.h>
- #include<algorithm>
- using namespace std;
- typedef long long LL;
- const int N = ;
- int p[N];
- void init(){
- for(int i=;i<=;i++){
- if(!p[i]){
- for(int j=i*i;j<=;j+=i){
- p[j] = true;
- }
- }
- }
- }
- int main()
- {
- init();
- int n;
- while(scanf("%d",&n)!=EOF){
- int sum = ;
- for(int i=;i<=n;i++){
- int v;
- scanf("%d",&v);
- if(!p[v]) sum+=v;
- }
- printf("%d\n",sum);
- }
- return ;
- }
hdu 5150(水题)的更多相关文章
- HDU-1042-N!(Java大法好 && HDU大数水题)
N! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Subm ...
- HDU 5391 水题。
E - 5 Time Limit:1500MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- hdu 1544 水题
水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...
- HDU排序水题
1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...
- hdu 2710 水题
题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...
- Dijkstra算法---HDU 2544 水题(模板)
/* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...
- hdu 5162(水题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...
- hdu 3357 水题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...
- hdu 5038 水题 可是题意坑
http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数 这个范围小 所以一个数组存是否存在的状态即可了 可是这句话真恶心 If not all ...
随机推荐
- Servlet过滤器---登录权限控制
实现了登录时权限控制:进入首页.登录页以及登录servlet时,不用验证权限:进入其它页面时,须验证是否登录,未登录则跳转到登录页. 一个简单的首页:index.jsp <%@ page lan ...
- Java-JNA使用心得
自上个月20号,历时整整一个月,终于找到工作入职了. 然后这段时间一直看公司的框架还有业务方面的东西.其实由于给分配了一个研究Java调用C语言接口的问题,导致框架业务方面的东西还不熟,然后现在手上又 ...
- JWT应用
调试器库简介问一件T恤! 精心制作 JSON Web令牌简介 新:免费获得JWT手册并深入学习JWT! 什么是JSON Web Token? JSON Web Token(JWT)是一个开放标准(RF ...
- codility
// you can also use imports, for example: // import java.util.*; // you can write to stdout for debu ...
- (原)C sharp杂谈记事(一)
题记)最是那一低头的温柔,像一朵睡莲花不胜凉风的娇羞 1)接收 公司的X部门有个APP小项目,APP后台是C sharp的MVC,提供了一个C sharp的web from做管理员操作的后台操作,此项 ...
- Windows下安装PHP及开发环境配置
一.Apache 因为Apache官网只提供源代码,如果要使用必须得自己编译,这里我选择第三方安装包Apache Lounge. 1. 进入Apachelounge官方下载地址:http://www. ...
- 转: jsp之c标签
http://www.gbsou.com/2009/10/12/1028.htmljsp标签之c标签 核心标签库 它是JSTL中的核心库,为日常任务提供通用支持,如显示和设置变量.重复使用一组项目.测 ...
- fragment中的WebView返回上一页
public final class Text1Fm extends Fragment { static WebView mWeb; private View mContentView; privat ...
- Thymeleaf 模板 在spring boot 中的引用和应用
Thymeleaf是一个java类库,他是一个xml/xhtml/html5的模板引擎和Struts框架的freemarker模板类似,可以作为mvc的web应用的view层. Thymeleaf还提 ...
- PHP文件操作函数及文件指针理解
知识点: 一.fopen(),文件打开函数,读写参数有: 1.R : 只读,指针在文件开头 2.r+:读写,指针同上 3.W :只写,写入前会删除文件内容,然后指针回到文件开头,文件不存在则创建 4 ...