当前位置: 代码迷 >> 综合 >> 1455 B - Jumps
  详细解决方案

1455 B - Jumps

热度:106   发布时间:2023-11-22 07:57:22.0

题目链接

https://codeforces.com/contest/1455/problem/B

题解

分类:
思维(cf的这个思维题,真的,阴间啊,呜呜呜)

代码:

#include <iostream>
using namespace std;
int main()
{
    int t, n, i, x,a[2000] = {
    0},ans;for (i = 1; i <= 1500; i++)a[i] = a[i - 1] + i;cin >> t;while (t--){
    cin >> x;for (i = 1; i <= 1500; i++){
    if (a[i] >= x){
    if (a[i] == x)cout << i << "\n";else if (a[i] - 1 == x)cout << i + 1 << "\n";elsecout << i << "\n";break;}}}return 0;
}