QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#580384#9381. 502 Bad Gatewaysyhyyds#WA 127ms3728kbC++17861b2024-09-21 21:37:382024-09-21 21:37:38

Judging History

你现在查看的是最新测评结果

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-21 21:37:38]
  • 评测
  • 测评结果:WA
  • 用时:127ms
  • 内存:3728kb
  • [2024-09-21 21:37:38]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
__int128 n;
__int128 read(){
    __int128 x=0,f=1;
    char ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-')f=-1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}
void print(__int128 x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);//注意这里是x>9不是x>10 (2019.10 wa哭了回来标记一下)
    putchar(x%10+'0');
}
__int128 gcd(__int128 a,__int128 b)
{    if(!b) return a;
      return gcd(b,a%b);
}
__int128 sum(__int128 x){
	return x*(x+1)/2;
}
int main(){
   int T;
   cin>>T;
   while(T--)
    {
     n=read();
     __int128 sm=sum(n);
       __int128 d=gcd(sm,n);
        sm/=d;
        n/=d;
        print(sm);
        printf(" ");
        print(n);
        printf("\n");
   }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3728kb

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 127ms
memory: 3572kb

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
1000000001 2
1 1
1 1
1000000001 2
1 1
1000000001 2
1 1
1 1
1 1
1000000001 2
1 1
1 1
1000000001 2
1 1
1000000001 2
1000000001 2
1 1
1000000001 2
1 1
1 1
1000000001 2
1 1
1000000001 2
1000000001 2
1 1
1000000001 2
1000000001 2
1000000001 2
1000000001 2
1000000001 2
1000000001 2
1 1
1 1
1000000001 ...

result:

wrong answer 2nd lines differ - expected: '1999961560 44721', found: '1000000001 2'