各位大佬帮忙看看吧,实在debug不出来了。。。
查看原帖
各位大佬帮忙看看吧,实在debug不出来了。。。
242235
ITC_天泠楼主2020/10/19 07:30
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll t,n,a[3123456],tot=0;
void pre(){
	ll temp=(1ll<<31);
	for(ll i=1;(1+i)*i/2<=temp;i++){
		a[++tot]=(1+i)*i/2;
//		cout<<a[i]<<endl;
	}
}
int main(){
	cin>>t;
	pre();
	while(t--){
		scanf("%lld",&n);
		ll gk=lower_bound(a+1,a+1+tot,n)-a;
		cout<<n-a[gk-1]<<endl;
	}
}
2020/10/19 07:30
加载中...