QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#726955 | #7731. Simple Calculation | TheZone | AC ✓ | 1ms | 3768kb | C++20 | 1.7kb | 2024-11-09 10:38:44 | 2024-11-09 10:38:44 |
Judging History
answer
#include<bits/stdc++.h>
#define Yukinoshita namespace
#define Yukino std
using Yukinoshita Yukino;
int read()
{
int s=0;
char ch=getchar();
while(ch<'0'||ch>'9') ch=getchar();
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s;
}
set<int> st,mpp;
void solve(int x)
{
if(mpp.find(x)!=mpp.end()) return;
mpp.insert(x);
for(int i=2;i*i<=x;i++)
if(x%i==0)
{
st.insert(i);
while(x%i==0) x/=i;
solve(i-1);
}
if(x>1)
st.insert(x),solve(x-1);
}
const int mod=998244353;
int qpow(int a,int p)
{
int mul=1;
for(;p;p>>=1)
{
if(p&1) mul=1ll*mul*a%mod;
a=1ll*a*a%mod;
}
return mul;
}
pair<int,int> pt[1000];
int mp[1000][1000],tp[1000],asd[1000];
bool fl[1000];
int main()
{
int n=read(),kk=read(),t=read(),m=0,i,j,k,B=100;
solve(n),solve(kk);
for(auto i:st)
{
pt[++m].first=i;
for(j=n;j%i==0;j/=i)
pt[m].second++;
for(j=kk;j%i==0;j/=i)
asd[m]++;
}
for(i=1;i<=m;i++)
for(j=1;j<i;j++)
for(k=pt[i].first-1;k%pt[j].first==0;k/=pt[j].first)
mp[i][j]++;
for(i=0;i<=B&&t;i++,t--)
{
if(i==B)
{
for(j=1;j<=m;j++)
tp[j]=pt[j].second;
}
for(j=1;j<=m;j++)
{
for(k=1;k<j;k++)
if((fl[j]||pt[j].second)&&mp[j][k])
(pt[k].second+=mp[j][k])%=mod-1,fl[k]|=pt[k].second>100;
pt[j].second=(pt[j].second-(fl[j]||pt[j].second)+mod-1)%(mod-1);
}
for(j=1;j<=m;j++)
(pt[j].second+=asd[j])%=mod-1;
if(i==B)
{
for(j=1;j<=m;j++)
tp[j]=(pt[j].second-tp[j]+mod-1)%(mod-1);
}
}
for(i=1;i<=m;i++)
pt[i].second=(pt[i].second+1ll*tp[i]*t)%(mod-1);
int mul=1;
for(i=1;i<=m;i++)
mul=1ll*mul*qpow(pt[i].first,pt[i].second)%mod;
cout<<mul;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3632kb
input:
5 3 4
output:
12
result:
ok 1 number(s): "12"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
114514 1919 810
output:
565299374
result:
ok 1 number(s): "565299374"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
471056515 515533912 819244330
output:
80333096
result:
ok 1 number(s): "80333096"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
946218581 843926244 6
output:
755554678
result:
ok 1 number(s): "755554678"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
243387905 466399354 1
output:
31994781
result:
ok 1 number(s): "31994781"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
949360206 9 852103989
output:
365360502
result:
ok 1 number(s): "365360502"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
340961378 1 178140501
output:
1
result:
ok 1 number(s): "1"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
5 766412355 428385669
output:
897576220
result:
ok 1 number(s): "897576220"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
1 300888960 118289676
output:
857071614
result:
ok 1 number(s): "857071614"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
453780402 58151770 899609894
output:
706813577
result:
ok 1 number(s): "706813577"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
275696978 189635629 382033568
output:
11769055
result:
ok 1 number(s): "11769055"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
6 5 338958244
output:
551186036
result:
ok 1 number(s): "551186036"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
1 1 159861640
output:
1
result:
ok 1 number(s): "1"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
1 1 1
output:
1
result:
ok 1 number(s): "1"
Test #15:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
6 9 6
output:
4374
result:
ok 1 number(s): "4374"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
7 1 168020519
output:
1
result:
ok 1 number(s): "1"
Test #17:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
2 2 491687011
output:
2
result:
ok 1 number(s): "2"
Test #18:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
1 8 91696528
output:
853564424
result:
ok 1 number(s): "853564424"
Test #19:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
118545549 883707189 308468280
output:
96220390
result:
ok 1 number(s): "96220390"
Test #20:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
848437432 40243163 134551129
output:
928606698
result:
ok 1 number(s): "928606698"
Test #21:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
457002000 698634270 824099416
output:
55802587
result:
ok 1 number(s): "55802587"
Test #22:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
635085424 272183114 417879969
output:
972594155
result:
ok 1 number(s): "972594155"
Test #23:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
518201552 700507766 156884715
output:
503492585
result:
ok 1 number(s): "503492585"
Test #24:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
401317681 569023907 455697973
output:
823384904
result:
ok 1 number(s): "823384904"
Test #25:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
874368401 847605455 49478526
output:
311608752
result:
ok 1 number(s): "311608752"
Test #26:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
757484529 716121595 493515976
output:
778366586
result:
ok 1 number(s): "778366586"
Test #27:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
935567953 289670440 87296530
output:
89278293
result:
ok 1 number(s): "89278293"
Test #28:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
818684081 863219284 531333979
output:
267225381
result:
ok 1 number(s): "267225381"
Test #29:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
291734801 586511232 125114533
output:
276488454
result:
ok 1 number(s): "276488454"
Test #30:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
144682559 109971719 509289880
output:
445774576
result:
ok 1 number(s): "445774576"
Test #31:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
617733279 388553267 248294626
output:
830938463
result:
ok 1 number(s): "830938463"
Test #32:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
500849407 962102111 252140587
output:
156729296
result:
ok 1 number(s): "156729296"
Test #33:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
678932831 685394060 991145333
output:
577816661
result:
ok 1 number(s): "577816661"
Test #34:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
857016255 258942904 584925887
output:
840731297
result:
ok 1 number(s): "840731297"
Test #35:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
35099679 127459045 178706440
output:
25377714
result:
ok 1 number(s): "25377714"
Test #36:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
918215807 406040593 622743890
output:
880059895
result:
ok 1 number(s): "880059895"
Test #37:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
96299231 979589437 216524444
output:
474172286
result:
ok 1 number(s): "474172286"
Test #38:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
274382655 848105578 955529189
output:
432816350
result:
ok 1 number(s): "432816350"
Test #39:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
452466079 276430230 549309743
output:
648960299
result:
ok 1 number(s): "648960299"
Test #40:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
90024778 803396608 83109994
output:
20645984
result:
ok 1 number(s): "20645984"
Test #41:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
114514 997619999 888888888
output:
573811358
result:
ok 1 number(s): "573811358"
Test #42:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
997413839 997281359 997118399
output:
409436500
result:
ok 1 number(s): "409436500"
Test #43:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
998244352 998244352 998244352
output:
499122175
result:
ok 1 number(s): "499122175"
Extra Test:
score: 0
Extra Test Passed