Educational Codeforces Round 10(A)模拟
来源:互联网 发布:天津软件培训基地 编辑:程序博客网 时间:2024/05/17 20:00
题意:有一只毛毛虫,在高度为h1的地方往h2的地方爬,白天爬的速度是a,晚上掉下的速度是b,每天回在下午2点去查看毛毛虫有没有爬到目的地,问需要等几天,如果不能到达h2那么输出-1.
题解:直接模拟就好啦,输出-1只有一种情况就是速度a<=b,而且第一次爬不到h2,那么就永远都爬不上了。输出-1, 否则就模拟一下就好了
#include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<iostream> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue> #include<string> #include<bitset> #include<utility> #include<functional> #include<iomanip> #include<sstream> #include<ctime> using namespace std; #define N int(1e5) #define inf int(0x3f3f3f3f) #define mod int(1e9+7) typedef long long LL; #ifdef CDZSC #define debug(...) fprintf(stderr, __VA_ARGS__) #else #define debug(...) #endif int main() { #ifdef CDZSC freopen("i.txt", "r", stdin); //freopen("o.txt","w",stdout); int _time_jc = clock(); #endif int a,b,h1,h2;while(~scanf("%d%d%d%d",&h1,&h2,&a,&b)){int h=h2-h1;int v=a-b;int num=0,ans=0;if(a<=b&&num+8*a<h){puts("-1");continue;}while(1){if(num+8*a<h){num+=(12*v);}else{break;}ans++;}printf("%d\n",ans);}#ifdef CDZSC debug("time: %d\n", int(clock() - _time_jc)); #endif return 0; }
0 0
- Educational Codeforces Round 10(A)模拟
- Educational Codeforces Round 2 A. Extract Numbers(模拟)
- Educational Codeforces Round 1 (A)模拟
- Educational Codeforces Round 5(A) 模拟
- Educational Codeforces Round 6 (B)模拟
- Educational Codeforces Round 7(B)模拟
- Educational Codeforces Round 11(B)模拟
- Educational Codeforces Round 6 (A)贪心
- Educational Codeforces Round 7(A)数学
- Educational Codeforces Round 16 (A-E)
- Educational Codeforces Round 30(A+B)
- Educational Codeforces Round 1 B.Queries on a String(模拟)
- Educational Codeforces Round 2 A.Extract Numbers(模拟)
- Educational Codeforces Round 7-A. Infinite Sequence(模拟)
- Educational Codeforces Round 9-A. Grandma Laura and Apples(模拟)
- Educational Codeforces Round 16 A. King Moves【模拟】
- Educational Codeforces Round 1 A. Tricky Sum(简单模拟求和)
- Educational Codeforces Round 5-A. Comparing Two Long Integers(模拟)
- VC与JavaScript交互(三) ———— JS调用C++
- 仿招商银行加载loading效果
- 唯爱小粽子:软件架构的条件(architecture prerequisite)
- cvc-complex-type.2.4.d: 发现了以元素 'd:skin' 开头的无效内容。此处不应含有子元素。
- 字符设备驱动基本框架
- Educational Codeforces Round 10(A)模拟
- 黑马程序员——JAVA学习日志之IO流(一)
- 《秋诗之立残阳》
- 2016/03/26-JavaEE框架
- windows 80端口被占用的解决方法
- 匹配html中a标签的内容
- Layout Inflation不能这么用
- Android编码规范
- java 线程创建的方法