题解:CF2051B Journey
CF2051B Journey
思路
先计算
- 剩下的
n=0 :答案为num\cdot3 - 剩下的
n\le a :答案为num\cdot3+1 - 剩下的
a\lt n\le a+b :答案为num\cdot3+2 - 剩下的
a+b\lt n :答案为num\cdot3+3 AC 代码
#include<bits/stdc++.h> using namespace std; long long t,n,a,b,c; int main(){ cin>>t; while(t--){ cin>>n>>a>>b>>c; long long num=n/(a+b+c); n-=num*(a+b+c); if(n==0) cout<<num*3<<endl; else if(a>=n) cout<<num*3+1<<endl; else if(a+b>=n) cout<<num*3+2<<endl; else cout<<num*3+3<<endl; } return 0; }AC 记录