Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
37441 李羽乔 【S】T2 C++ 解答错误 0 243 MS 256 KB 892 2025-03-30 16:24:13

Tests(0/5):


#include<bits/stdc++.h> using namespace std; int T; __int128 n,m,ans,maxn; __int128 read() { __int128 x=0,w=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-') w=-w; ch=getchar(); } while(ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); } return w*x; } void write(__int128 x) { if(x<0) { putchar('-'); x=-x; } if(x>9) write(x/10); putchar(x%10+'0'); } signed main(){ cin>>T; while(T--){ maxn=0; ans=1; n=read(); m=read(); for(__int128 i=2;i<=m;i++){ __int128 cnt=0; for(__int128 j=0;j<i;j++){ __int128 x=(n*j+1)/(i-1),y=(n*j+n+1)/i; if(x*(i-1)<(n*j+1)){ x=x+1; } if(y*i<(n*j+n+1)){ y=y+1; } cnt=cnt+(x+y-1)*(y-1-x+1)/2; //cout<<x<<" "<<y<<endl; } if(cnt>maxn){ maxn=cnt; ans=i; } } write(ans); cout<<endl; } return 0; }


测评信息: