QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#243104 | #6727. K-hour Clock | Lionel_ZQY# | WA | 248ms | 3680kb | C++20 | 546b | 2023-11-07 21:01:35 | 2023-11-07 21:01:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve(){
i64 x,y,z;
cin>>x>>y>>z;
if(x+y<z){
cout<<"-1\n";
return ;
}else if(x+y==z){
cout<<z+1LL<<'\n';
return ;
}
i64 num=x+y-z,ans=-1;
for(i64 i=2;i*i<=num;i++){
if(num%i==0){
if(num/i>z&&num/i>x){
ans=num/i;
break;
}else{
break;
}
}
}
cout<<ans<<'\n';
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3680kb
input:
4 11 18 5 3 49 4 1 9 1 1 3 10
output:
12 24 3 -1
result:
ok 4 cases
Test #2:
score: -100
Wrong Answer
time: 248ms
memory: 3624kb
input:
100000 186826504 580942638 34507146 409013320 825277663 642758065 221040339 32805624 253845963 759538401 529610463 314034771 591738614 223935926 591499221 272890462 257036262 529926724 644722795 540369561 79342760 141738127 915104743 658190166 378771709 735410115 474472687 550207480 676282297 233056...
output:
366630998 -1 253845964 -1 -1 529926725 -1 -1 -1 601592069 -1 -1 673441983 -1 -1 -1 643543523 -1 398961578 -1 488183711 524483170 -1 -1 611749282 -1 -1 862956524 -1 -1 -1 410033100 -1 808528037 -1 -1 970821147 433733581 -1 644562937 -1 -1 -1 -1 -1 808841222 -1 -1 821321287 939730707 534290021 -1 -1 -...
result:
wrong answer Case #4: Participant says impossible but a solution actually exists (x = 759538401, y = 529610463, z = 314034771, k = -1)