POJ-3619 Speed Reading
#include <iostream>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define ios ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N = 1e6 + 10;
void solve()
{
ll n, k, s, t, r;
cin >> n >> k;
while (k--)
{
cin >> s >> t >> r;
ll ss = n; //ss==未读页数
ll tt = 0; //tt==用时
while (ss > s * t) //当未读页数>连续t秒读的总页数时循环
{
tt += t + r;
ss -= s * t;
}
//处理不够连续t秒读的页数
tt += ss / s;
if (ss % s) tt++;
cout << tt << endl;
}
}
int main()
{
IOS
solve();
return 0;
}