http://acm.hdu.edu.cn/showproblem.php?pid=5151

直接判断是不是素数,然后再注意1就行。

 #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; int n;
int a[];
bool f[]; void Get_prime()
{
f[]=true;
for(int i=; i<=; i++)
{
if(!f[i])
{
for(int j=i*i; j<=; j+=i)
{
f[j]=true;
}
}
}
} int main()
{
Get_prime();
while(scanf("%d",&n)!=EOF)
{
memset(a,,sizeof(a));
int ans=;
for(int i=; i<n; i++)
{
scanf("%d",&a[i]);
if(a[i]==) ans+=a[i];
else
{
if(!f[a[i]])
{
ans+=a[i];
}
}
}
printf("%d\n",ans);
}
return ;
}

hdu 5150 Sit sit sit的更多相关文章

  1. BestCoder24 1001.Sum Sum Sum(hdu 5150) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5150 题目意思:就是直接求素数. 不过 n = 1,也属于答案范围!!只能说,一失足成千古恨啊---- ...

  2. hdu 5150 Sum Sum Sum 水

    Sum Sum Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Prob ...

  3. HDU 5150 Sum Sum Sum 素数

    Sum Sum Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  4. hdu 5150(水题)

    Sum Sum Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  5. HDU 1584 蜘蛛牌

    题解:纸牌只能移到比其大一的纸牌上,所以移动方向是定的,那么,就只有选择移动先后的问题了,对于决定要移的纸牌,比如1,如果2,3,4都是visited的状态,那么1一定是要移动到5的,因为2,3,4一 ...

  6. HDU——2723Electronic Document Security(STL map嵌套set做法)

    Electronic Document Security Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  7. hdu 5012 bfs 康托展开

    Dice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submi ...

  8. HDU 5151 Sit sit sit 区间DP + 排列组合

    Sit sit sit 问题描述 在一个XX大学中有NN张椅子排成一排,椅子上都没有人,每张椅子都有颜色,分别为蓝色或者红色. 接下来依次来了NN个学生,标号依次为1,2,3,...,N. 对于每个学 ...

  9. HDU 5151 Sit sit sit 区间dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5151 题解: 有n个椅子,编号为1到n. 现在有n个同学,编号为1到n,从第一个同学开始选择要坐的位 ...

随机推荐

  1. Android ADT离线更新办法

    Troubleshooting ADT Installation If you are having trouble downloading the ADT plugin after followin ...

  2. 08_android入门_android-async-http开源项目介绍及用法

    android-async-http开源项目可以是我们轻松的获取网络数据或者向server发送数据.使用起来很easy,关于android-async-http开源项目的介绍内容来自于官方:http: ...

  3. MySQL的优化点总结---通过计算多种状态的百分比看MySQL的性能情况

    1 读写比例: show global status like 'com_select';  获得服务器启动到目前查询操作执行的次数:show global status like 'com_inse ...

  4. java中关于public class

    在编写类的时候可以使用两种方式定义类:     public class定义类:     class定义类: 1,如果一个类声明的时候使用了public class进行了声明,则类名称必须与文件名称完 ...

  5. TCP/IP协议原理与应用笔记01:OSI网络参考模型

    1.OSI参考模型 第7层应用层:直接对应用程序提供服务,应用程序可以变化,但要包括电子消息传输   第6层表示层:格式化数据,以便为应用程序提供通用接口.这可以包括加密服务   第5层会话层:在两个 ...

  6. Extending Robolectric

    Robolectric is a work in progress, and we welcome contributions from the community. We encourage dev ...

  7. 知识点摸清 - - position属性值之relative与absolute

    两者共同特点是: 改变文档流 激活元素left.top.right.bottom.z-index属性 让元素”浮起来“,z-index>0 不同的是: 1.position:relative 会 ...

  8. hibernate4.3.8整合struts2过程中遇到的问题

    1.遇到的异常: Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to ...

  9. 关于cocoapods和swift中使用oc第三方

    mac 系统自带ruby,使用cocoapods,直接安装cocoapods就行 终端:$ sudo gem install cocoapods {安装较慢是因为有墙,查看ruby镜像列表:$ gem ...

  10. >=ios8 应用内跳转到系统设置界面-openURL

    iOS8以后,苹果允许从应用内跳转到系统设置,但是调试结果表明,跳不到具体的设置项,使用前应该判断当前是否能够跳转到系统设置. 代码: NSURL *url = [NSURL URLWithStrin ...