1011번 - Fly me to the Alpha Centauri
#include <iostream>#include <string>using namespace std;
int n;long long int x, y;long long int m;long long int cnt = 1;long long int temp = 1;int main(){ cin >> n;
for (int i = 1; i <= n; i++) { cin >> x >> y;
m = y - x; while (m > temp) { temp += cnt++;
//cout << "m-- " << m << "temp-- " << temp << " cnt-- " << cnt << endl; }
cout << cnt << endl; cnt = 1; temp = 1; }
}
댓글을 작성하려면 로그인해야 합니다.
omingyu 7년 전
#include <iostream>
#include <string>
using namespace std;
int n;
long long int x, y;
long long int m;
long long int cnt = 1;
long long int temp = 1;
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> x >> y;
m = y - x;
while (m > temp)
{
temp += cnt++;
//cout << "m-- " << m << "temp-- " << temp << " cnt-- " << cnt << endl;
}
cout << cnt << endl;
cnt = 1;
temp = 1;
}
}