【Codeforces Round #443 (Div. 2) A】Borya's Diagnosis

【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

模拟

【代码】

#include <bits/stdc++.h>
using namespace std;

const int N = 1000;

int n;
pair <int,int> a[N+10];


int main(){
//	freopen("rush.txt","r",stdin);
	scanf("%d",&n);
	for (int i = 1;i <= n;i++)
		scanf("%d%d",&a[i].first,&a[i].second);
	int now = a[1].first;
	for (int i = 2;i <= n;i++){
	 	if (now < a[i].first){
	 		now = a[i].first;
	 	}else{
	 		//now >= a[i].first;
	 		int pre = now;
	 		int temp = now - a[i].first;
	 		temp = (temp-1)/a[i].second + 1;
	 		now = a[i].first + temp*a[i].second;
		 	if (pre==now) now += a[i].second;
	 	}
	}
	printf("%d\n",now);
	return 0;
}


posted @ 2017-10-27 09:18  AWCXV  阅读(174)  评论(0编辑  收藏  举报