QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#563083#5196. 幸运位置elegiaAC ✓23ms11224kbPython3357b2024-09-14 02:28:502024-09-14 18:33:40

Judging History

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

  • [2024-09-14 18:33:40]
  • 评测
  • 测评结果:AC
  • 用时:23ms
  • 内存:11224kb
  • [2024-09-14 02:28:50]
  • 提交

answer

import math, random
T = int(input())
for rep in range(0, T):
    a, b, c = input().split()
    a = int(a)
    b = int(b)
    c = int(c)
    if math.gcd(math.gcd(a, b), c) != 1:
        print(-1)
        continue
    while True:
        n = random.randint(0, c - 1)
        if math.gcd(a * n + b, c) == 1:
            print(n)
            break

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 13ms
memory: 11000kb

input:

10
65494577715653854 11221953382405716 1302352773042732
619584057283370697 18562598051556124 415711731533620
884521003237724575 15529746088977290 295327780048644
617020977808840131 22233480296532428 437625253283372
484973174523133295 809660155435376 1914474190205472
391168693519019477 17507546702984...

output:

-1
325680857774969
149127379707353
104155289102969
1554773054459341
3033467898449911
6207135083853301
22766912597146
2481985233178073
2362490726781907

result:

ok accepted

Test #2:

score: 0
Accepted
time: 6ms
memory: 11092kb

input:

2
9754163734121579145093859297421922314613863462279089293021259149905799626777976944549496594799837760395584804584599805666054497375782930876272590582249376078415071204137492186524460490784465502472489171418177308018110487249425841910984312239020914024182215170835597260762731374976021596784665601540...

output:

-1
529905135602269997553464219786311368200363777085628356562239896214551230360127629397151688534801262570086329309943619154579303590313927216254653800227844303497210312288641839191836319833282991255668428121199214425352363693011851064932930091063124976525111005870912295570246009958529325851171657301...

result:

ok accepted

Test #3:

score: 0
Accepted
time: 21ms
memory: 10952kb

input:

10
704307121567362844319240385923855476203008053774026789061071599725185251350284664882661058643869808828806581291004650502482315240623682279254131860708681905425046266094718930026777795500161860308224020132624974072263086632486584543970468189727245453350282208104392487200629158706597818752453673613...

output:

488316236141755697441474736101448305678506948967574114352885820906629585769484259885154873340000305792563210265017790485402822731457756414014567665436611122552258496213412664917568087066153479936669083787815244489292243170485793505224248180061705056580494777469591130282963414242925381939600033332252...

result:

ok accepted

Test #4:

score: 0
Accepted
time: 15ms
memory: 11224kb

input:

10
553398019668781125547036683856610392745044446871945592483076774472489697615684391555437911742940573519487687909623877939587710678466030998921874486442673646608354570059707874465357432817899627405405263326600254747822638648701944728111381052982592165436606976783501531652560225570311428528115088643...

output:

578364372970652007535083226015356963684279694696083132111164693391776513795805424554919003855513358759097063001244610283329718108587917579482933173062060459167586156104716729381821369953742584540783721007497808928016548738938861984147281046542938541940333738967398384996234480095706574002340294760163...

result:

ok accepted

Test #5:

score: 0
Accepted
time: 23ms
memory: 11024kb

input:

10
125621444382184090106678286844930978284143885089893479885818808456120954887812111835873349406310208183656174593872259139077022507849596056105028132444323468851334748699363012336163253490756036851004293364092499038261353524106728134935172969084175817235519439575613103928388040380253279426543076733...

output:

291948656119938607394233470170630621274271387297135941447158588967830381043835134964170340924833310108208306079785171049386265345511810340939079165628948112240083846827437693891200016605119779614894027033791556214702189443947285707990499373665329543142539387575693620021069697228540377333008592173428...

result:

ok accepted