Problem description

«One dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine.

However, just counting dragons was boring as well, so she entertained herself at best she could. Tonight she imagined that all dragons were here to steal her, and she was fighting them off. Every k-th dragon got punched in the face with a frying pan. Every l-th dragon got his tail shut into the balcony door. Every m-th dragon got his paws trampled with sharp heels. Finally, she threatened every n-th dragon to call her mom, and he withdrew in panic.

How many imaginary dragons suffered moral or physical damage tonight, if the princess counted a total of d dragons?

Input

Input data contains integer numbers k, l, m, n and d, each number in a separate line (1 ≤ k, l, m, n ≤ 10, 1 ≤ d ≤ 105).

Output

Output the number of damaged dragons.

Examples

Input

1
2
3
4
12

Output

12

Input

2
3
4
5
24

Output

17

Note

In the first case every first dragon got punched with a frying pan. Some of the dragons suffered from other reasons as well, but the pan alone would be enough.

In the second case dragons 1, 7, 11, 13, 17, 19 and 23 escaped unharmed.

解题思路:题目的意思就是每x(x=k,l,m,n)就会受到伤害,一共有d条龙,求最终受到伤害的龙有多少条。累加和简单标记一下每x(x=k,l,m,n)条龙为true(初始值都为false),最后统计一下有多少个true就是有多少条龙受到伤害,水过。

AC代码:

 #include<bits/stdc++.h>
using namespace std;
int d,s[],num=;bool used[];
int main(){
for(int i=;i<;++i)cin>>s[i];
cin>>d;
memset(used,false,sizeof(used));
for(int i=;i<;++i)
for(int j=s[i];j<=d;j+=s[i])
used[j]=true;
for(int i=;i<=d;++i)
if(used[i])num++;
cout<<num<<endl;
return ;
}

C - Insomnia cure的更多相关文章

  1. CF 148A Insomnia cure

    题目链接:传送门 题目大意:就是给四个数,和一个d,问1-d中有多少个数字不是那四个数的倍数; 这道题的d数据很小直接暴力可以过: 暴力代码:时间复杂度O(1): #include<stdio. ...

  2. codeforces水题100道 第四题 Codeforces Round #105 (Div. 2) A. Insomnia cure (math)

    题目链接:http://www.codeforces.com/problemset/problem/148/A题意:求1到d中有多少个数能被k,l,m,n中的至少一个数整出.C++代码: #inclu ...

  3. CF148A Insomnia cure

    公主睡前数龙, 每隔k, l, m, n只都会用不同的技能攻击龙. 假定共数了d只龙, 问共有多少龙被攻击了. 思路: 用一个visit数组记录被攻击过的dragon, 最后遍历visit数组统计被攻 ...

  4. Codeforces Round #105 (Div. 2) ABCDE

    A. Insomnia cure 哎 只能说英语太差,一眼题我看了三分钟. 题意:给5个数k, l, m, n 和 d,求1~d中能被k, l, m, n 至少一个整除的数的个数. 题解:…… 代码: ...

  5. codeforcess水题100道

    之所以在codeforces上找这100道水题的原因是为了巩固我对最近学的编程语言的掌握程度. 找的方式在codeforces上的PROBLEMSET中过的题最多的那些题里面出现的最前面的10个题型, ...

  6. 2020.12.20vj补题

    A - Insomnia cure 题意:一共s只龙,每隔k,l,m,n只龙就会受伤,问这s只龙有多少龙是受伤的 思路:看起来题目范围并不是很多,直接进行循环判断 代码: 1 #include< ...

  7. 16年青岛网络赛 1002 Cure

    题目链接:http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1002&cid=723 Cure Time Limit: 30 ...

  8. hdu5879 Cure

    题目链接:hdu5879 Cure 题解:用字符串输入.n很大时答案趋近与(π^2)/6. #include<cstdio> #include<algorithm> #incl ...

  9. HDU 5879 Cure

    Cure Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

随机推荐

  1. 创建dml触发器

    -实现删除学生信息时把该学生的成绩记录全部清空 --判断触发器是否存在 if exists(select * from sysobjects where name = 'delete_student' ...

  2. C# 检测dll的新版本号方法

    FileVersionInfo info = FileVersionInfo.GetVersionInfo(YourFileNameHere);string version = info.FileMa ...

  3. emlog通过pjax实现无刷新加载网页--完美解决cnzz统计和javascript失效问题

    想要更详细了解pjax,需要查看官网 或者看本站文章:jQuery.pjax.js:使用AJAX和pushState无刷新加载网页(官网教程中文翻译) 效果看本站,音乐无刷新播放,代码高亮和复制js加 ...

  4. nginx_安装测试

    首先安装环境: [root@local nginx-1.9.14]#  yum install gcc-c++  pcre pcre-devel  zlib zlib-devel openssl op ...

  5. LINUX命令行如何查看memcache运行状态

    (附加)如何查看memcache服务器端版本:  ./memcached  -h memcache的运行状态可以方便的用 stats 命令显示. 首先用telnet 127.0.0.1 11211这样 ...

  6. 模拟登录新浪微博(Python)

    PC 登录新浪微博时, 在客户端用js预先对用户名.密码都进行了加密, 而且在POST之前会GET 一组参数,这也将作为POST_DATA 的一部分. 这样, 就不能用通常的那种简单方法来模拟POST ...

  7. 【转载】JSP详解(四大作用域九大内置对象等)

    前面讲解了Servlet,了解了Servlet的继承结构,生命周期等,并且在其中的ServletConfig和ServletContext对象有了一些比较详细的了解,但是我们会发现在Servlet中编 ...

  8. PAT_A1134#Vertex Cover

    Source: PAT A1134 Vertex Cover (25 分) Description: A vertex cover of a graph is a set of vertices su ...

  9. Codeforces Round #547 (Div. 3) E. Superhero Battle

    E. Superhero Battle A superhero fights with a monster. The battle consists of rounds, each of which ...

  10. request.getScheme()、 request.getServerName() 、 request.getServerPort() 、 request.getContextPath()

    <% String basePath = request.getScheme() + "://" + request.getServerName() + ":&qu ...