617A题目网址
题目解析
1.输入x,能够通过1,2,3,4,5去到达x,求最小到达x的步数.
举例:
输入:
12
输出:
3
2.注意点:
要最小的步数,所以直接使用最大的5去比较判断
1)当x<=5时,只需要1
2)当x>5时,如果x%5==0(x能整除5),只需要x/5步数,不能整除则需要x/5+1步数
代码
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{int x,count=0;scanf("%d",&x);// 1, 2, 3, 4 or 5if(x<=5){count=1;}else {if(x%5==0)//判断是否能整除5{count=x/5;}else{count=x/5+1;}}printf("%d",count);system("pause");getchar();return 0;
}