codeforces 617A-C语言解题报告
生活随笔
收集整理的這篇文章主要介紹了
codeforces 617A-C语言解题报告
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
617A題目網址
題目解析
1.輸入x,能夠通過1,2,3,4,5去到達x,求最小到達x的步數(shù).
舉例:
輸入:
12
輸出:
3
2.注意點:
要最小的步數(shù),所以直接使用最大的5去比較判斷
1)當x<=5時,只需要1
2)當x>5時,如果x%5==0(x能整除5),只需要x/5步數(shù),不能整除則需要x/5+1步數(shù)
代碼
#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; }總結
以上是生活随笔為你收集整理的codeforces 617A-C语言解题报告的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 安卓内边距padding与外边距magr
- 下一篇: 英语一段落排序题技巧