## [題目連結](https://zerojudge.tw/ShowProblem?problemid=h660) ## 解題想法 * 每輸入一次就計算位置,依不動、接球、閃避的順序考慮狀況 ## 花費的時間:10分鐘 ## 程式碼 ```cpp=01 #include<cstdio> #include<cmath> int main(){ int x,r,v,n,i; scanf("%d%d%d",&x,&r,&v); scanf("%d",&n); for(i=0;i<n;i++){ int p,s; scanf("%d%d",&p,&s); if(abs(x-p)<=r){ if(s<=v){ x=p; } else{ if(x>p)x+=15; else x-=15; } } } printf("%d",x); }
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up