3 solutions

  • 2
    @ 2024-3-20 23:05:11
    #include<bits/stdc++.h>
    using namespace std;
    int n,m,p;
    int main(){
    	cin>>n>>m>>p;
    	m<=n?cout<<(n-m)/p+1:cout<<(n-m)/p;
    	return 0;
    }
    

    记得判断啊

    • 2
      @ 2023-12-24 10:08:25
      #include<iostream>
      using namespace std;
      int main(){
      	int n,m,p,s=0;
      	cin>>n>>m>>p;
      	s=(n-m)/p;
      	if(m<=n) s++;
      	cout<<s;
      	return 0;
      }
      
      • 1
        @ 2023-10-28 13:10:14

        没必要用循环,用一个小小的数学运算

        #include<iostream>
        using namespace std;
        int main()
        {
         int n,m,p,s=0;
         cin>>n>>m>>p;//输入
         s=(n-m)/p;//减掉开始的的Day再除隔一次的Days
         if(m<=n)//特判,检测开头时是否有
          s++;
         cout<<s;//输出
         return 0;//完结散花!
        }
        
        • 1

        Information

        ID
        931
        Time
        1000ms
        Memory
        256MiB
        Difficulty
        8
        Tags
        (None)
        # Submissions
        263
        Accepted
        50
        Uploaded By