QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#581637 | #9381. 502 Bad Gateway | biaobenplus | AC ✓ | 552ms | 5712kb | C++17 | 1.9kb | 2024-09-22 13:40:38 | 2024-09-22 13:40:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
#define int long long
const int INF = 4e18+5;
#define F(i,l,r) for(int i=l;i<=r;i++)
#define R(i,l,r) for(int i=r;i>=l;i--)
#define vv vector
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
//const int mod = 998244353;
const int mod = 1e9+7;
const int M = 1e7+5;
int b[N],dp[N],vis[N],pri[N],a[N],ans1[N],ans2[N],c[N];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int n,m,k,ans,x,y,n0,n2,m0,m2,op,op1,op2;
string s;
map<int,int>mp;
map<int,int>mmap;
//char mp[1005][1005];
//vector<int>v1[N],v2[N];
int lowbit(int x) {
return x&-x;
}
char xx[N];
bool temp;
int kuai(int x,int y){
int sum=1;
x%=mod;
while(y){
if(y%2){
y--;
sum*=x;
sum%=mod;
}
x*=x;
y/=2;
x%=mod;
}
return sum;
}
struct node{
int sum,l,r,add;
}tree[N];
bool check(int x){
int x0,y0,x1=(1+n)*n,y1=2;
y=x-1;
x0=(1+x)*x/2+(n-x);
y0=x;
if(y>0){
x1=(1+y)*y/2+(n-y);
y1=y;
}
//cout<<x0<<" "<<y0<<" "<<x1<<" "<<y1<<endl;
double shu1=1.0*x0/y0,shu2=1.0*x1/y1;
if(shu1<=shu2) {
op1=x0,op2=y0;
return true;
}
return false;
}
void solve()
{
cin>>n;
int l=1,r=n+1;
op1=(1+n)*n/2; op2=n;
while(l<r){
int mid=l+r>>1;
//cout<<mid<<"**"<<endl;
if(check(mid)) l=mid+1;
else r=mid;
}
op=__gcd(op1,op2);
cout<<op1/op<<" "<<op2/op<<endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0); // cin.tie(nullptr);
int T = 1;
cin >> T;
for (int i = 1; i <= T; i++)
{
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5704kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 398ms
memory: 5704kb
input:
1000000 1 1000000000 1 1 1000000000 1 1000000000 1 1 1 1000000000 1 1 1000000000 1 1000000000 1000000000 1 1000000000 1 1 1000000000 1 1000000000 1000000000 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1000000000 1 1000000000 1000000000 1000000000 1000000000 1 1 1 10000000...
output:
1 1 1999961560 44721 1 1 1 1 1999961560 44721 1 1 1999961560 44721 1 1 1 1 1 1 1999961560 44721 1 1 1 1 1999961560 44721 1 1 1999961560 44721 1999961560 44721 1 1 1999961560 44721 1 1 1 1 1999961560 44721 1 1 1999961560 44721 1999961560 44721 1 1 1999961560 44721 1999961560 44721 1999961560 44721 19...
result:
ok 1000000 lines
Test #3:
score: 0
Accepted
time: 552ms
memory: 5712kb
input:
1000000 158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202 971407775 628894325 731963982 822804784 450968417 430302156 982631932 161735902 880895728 923078537 707723857 189330739 910286918 802329211 404539679 303238506 317063340 492686568 773361868 125...
output:
316511467 17791 1755824328 41903 1204845831 34711 49954223 7068 1723292600 41513 623676492 17659 867864517 29460 952375859 30861 262700539 11461 422085442 20545 1942776701 44077 251551941 7093 1463896912 38261 1645584679 40566 901913913 30032 107573492 3667 1965228547 44331 323457022 17985 176178307...
result:
ok 1000000 lines
Extra Test:
score: 0
Extra Test Passed