Victor and Machine
来源:互联网 发布:2017nba总决赛球员数据 编辑:程序博客网 时间:2024/05/16 01:31
Victor and Machine
Accepts: 452
Submissions: 1123
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 131072/65536 K (Java/Others)
问题描述
Victor有一个机器,这个机器每次开启的瞬间会弹出一个小球,之后每隔w秒会弹出一个小球。因为机器不是很完善,该机器每开启x秒就得关闭y秒进行调整,在机器关闭的瞬间可能会有小球弹出,关闭之后一直到下一次开启之前都不会有小球弹出。0时刻,机器第一次开启,Victor想要知道第n个小球弹出的时刻,你能够告诉他吗?
输入描述
包含多组测试数据(最多一百组),每组测试数据一行。每行有四个由空格隔开的整数,分别为x、y、w和n,其含义如题中所示。1≤x,y,w,n≤100。
输出描述
每组测试数据输出一行一个整数,即第n个小球弹出的时刻。
输入样例
2 3 3 398 76 54 3210 9 8 100
输出样例
102664939
AC代码:
#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>using namespace std;int x,y,w,n,i;int cal(){int ans=0,cnt=0,count=0;while(1){for(i=0;i<=x;i+=w){cnt++;if(cnt>=n)return ans;ans+=w;}ans=(x+y)*(++count);}}int main(){while(~scanf("%d%d%d%d",&x,&y,&w,&n)){printf("%d\n",cal());}return 0;}
0 0
- Victor and Machine
- Victor and Machine
- hdu 5417 Victor and Machine
- hdu 5417 Victor and Machine
- HDU 5417 Victor and Machine
- HDU-5417Victor and Machine
- hdu 5417 Victor and Machine
- HDOJ 5417 Victor and Machine
- hdu 5417 Victor and Machine
- hdu 5417 Victor and Machine
- hdu 5417 Victor and Machine 思考题
- BC 52 div2 A Victor and Machine
- HDU5417 Victor and Machine 模拟题
- hdu 5417 Victor and Machine(简单数学题)
- hdu 5417 Victor and Machine(模拟)
- HDOJ 5417 Victor and Machine 水
- HDU 5417-Victor and Machine(水题)
- hdu 5417 Victor and Machine 模拟
- SSL与TLS的区别以及介绍
- 细说 iOS 消息推送
- Leet -- Remove Duplicates from Sorted Array
- 图解SSL/TLS协议
- 大数模板——参考《入门经典》
- Victor and Machine
- 部署Spring Boot应用
- PHP PDO 安全执行 set names utf8 的正确方法
- Oracle数据库迁移MySql
- Java关键字(基础学习用到)
- 了解自己的路线
- Netty5中的4种解码器
- C++ Primer 5e chapter 13.2
- php 分页操作(三)