QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#883412 | #9981. Collatz Conjecture | KafuuChinocpp | WA | 0ms | 1664kb | C++14 | 1.0kb | 2025-02-05 16:15:36 | 2025-02-05 16:15:37 |
Judging History
answer
#include <cstdio>
#include <algorithm>
using namespace std;
void Exgcd ( long long A, long long B, long long &k, long long &t )
{
if ( !B )
{
k = 1;
t = 0;
return;
}
Exgcd(B, A % B, k, t);
long long tmp = t;
t = -k - A / B * t;
k = -tmp;
// printf("A = %lld B = %lld k = %lld t = %lld\n", A, B, k, t);
return;
}
int T;
long long A, B, n;
void Work ()
{
scanf("%lld%lld%lld", &A, &B, &n);
if ( B == 1 )
{
if ( n <= A )
printf("Yes\n");
else
printf("No\n");
}
else
{
long long k, t;
Exgcd(A, B, k, t);
printf("k = %lld t = %lld\n", k, t);
t = ((t * (n % B)) % A + A) % A;
printf("t = %lld\n", t);
if ( n <= (n % B) + t * B )
printf("Yes\n");
else
printf("No\n");
}
return;
}
int main ()
{
scanf("%d", &T);
while ( T -- )
Work();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1664kb
input:
7 2 1 1 2 1 2 2 1 3 2 1 100 314 159 265 314 159 2653 314 159 26535
output:
Yes Yes No No k = -40 t = -79 t = 104 Yes k = -40 t = -79 t = 181 Yes k = -40 t = -79 t = 165 No
result:
wrong answer 5th words differ - expected: 'Yes', found: 'k'