• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C-Elephant(贪心)

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

Problem description

An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point x(x > 0) of the coordinate line. In one step the elephant can move 1, 2, 3, 4 or 5 positions forward. Determine, what is the minimum number of steps he need to make in order to get to his friend's house.

Input

The first line of the input contains an integer x (1 ≤ x ≤ 1 000 000) — The coordinate of the friend's house.

Output

Print the minimum number of steps that elephant needs to make to get from point 0 to point x.

Examples

Input

5

Output

1

Input

12

Output

3

Note

In the first sample the elephant needs to make one step of length 5 to reach the point x.

In the second sample the elephant can get to point x if he moves by 3, 5 and 4. There are other ways to get the optimal answer but the elephant cannot reach x in less than three moves.

解题思路:从起始点0出发到达终点x,输出这一过程所走的最少步数。做法:从大的步数往小的步数贪心即可,水过。

AC代码:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main(){
 4     int x,tmp,step=0,s[5]={5,4,3,2,1};
 5     cin>>x;
 6     for(int i=0;i<5;++i)
 7         if(x>=s[i]){step+=(tmp=x/s[i]);x-=tmp*s[i];}
 8     cout<<step<<endl;
 9     return 0;
10 }

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C/C++:printf的用法发布时间:2022-07-13
下一篇:
C语言宏定义#define用法发布时间:2022-07-13
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap