题意:蜗牛爬树问题;值得一提的是在第n天如果恰好在天黑时爬到END,则恰好整除,不用再+1;
day = (End - Begin - day0)/(12*(up-down))+1;
#include <iostream> #include <algorithm> #include <stdlib.h> #include <time.h> #include <cmath> #include <cstdio> #include <string> #include <cstring> #include <vector> #include <queue> #include <stack> #include <set> #define c_false ios_base::sync_with_stdio(false); cin.tie(0) #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3f #define zero_(x,y) memset(x , y , sizeof(x)) #define zero(x) memset(x , 0 , sizeof(x)) #define MAX(x) memset(x , 0x3f ,sizeof(x)) #define swa(x,y) {LL s;s=x;x=y;y=s;} using namespace std ; #define N 50005 const double PI = acos(-1.0); typedef long long LL ; int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); //ios_base::sync_with_stdio(false); cin.tie(0); int Begin, End, up, down; scanf("%d%d%d%d", &Begin, &End, &up, &down); int day0 = 8*up; int day; if(up-down <= 0){ if(End - Begin - day0 <=0) day = 0; else day = -1; }else{ if(End - Begin - day0 <=0) day = 0; else { if((End - Begin - day0)%(12*(up-down)) == 0) day = (End - Begin - day0)/(12*(up-down)); else day = (End - Begin - day0)/(12*(up-down))+1; } } cout<<day; return 0; }