QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#645915#7046. Function!SGColinAC ✓11ms1648kbC++171.1kb2024-10-16 20:27:322024-10-16 20:27:32

Judging History

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

  • [2024-10-16 20:27:32]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:1648kb
  • [2024-10-16 20:27:32]
  • 提交

answer

#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;typedef long double DB;
const int MOD=998244353,INV2=(MOD+1)/2,INV6=(MOD+1)/6;

int S,ans;LL n;

#define ADD(x,y) (((x)+(y))%MOD)
#define MUL(x,y) ((LL)(x)*(y)%MOD)
int S1(LL n) {return MUL(MUL(n%MOD,(n+1)%MOD),INV2);}
int S2(LL n) {return MUL(MUL(MUL(n%MOD,(n+1)%MOD),ADD((n<<1)%MOD,1)),INV6);}
int S3(LL n) {int s=S1(n);return MUL(s,s);}
DB pow(DB w,int b) {DB s;for (s=1;b;b>>=1,w=w*w) if (b&1) s=s*w;return s;}
int Pow(int w,int b) {int s;for (s=1;b;b>>=1,w=MUL(w,w)) if (b&1) s=MUL(s,w);return s;}
int main(){
    scanf("%lld",&n);
    for (S=1;(LL)S*S-1<=n;S++);S--;
    if (S>1){
        ans=ADD(S3(S),MOD-S3(1));
        ans=ADD(ans,MOD-ADD(S2(S),MOD-S2(1)));
    }
    ans=ADD(ans,MUL((n+1)%MOD,ADD(S1(n),MOD-S1(S))));
    ans=ADD(ans,MOD-ADD(S2(n),MOD-S2(S)));
    for (int i=2;(1LL<<i)<=n;i++){
        int now=0;
        for (int a=2;pow(a,i)<=n;a++){
            LL L=pow(a,i),R=min(pow(a,i+1)-1,(DB)n);
            now=ADD(now,MUL(a,(R-L+1)%MOD));
        }
        ans=ADD(ans,MUL(now,i));
    }
    printf("%d\n",ans);
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 1636kb

input:

10

output:

236

result:

ok 1 number(s): "236"

Test #3:

score: 0
Accepted
time: 0ms
memory: 1592kb

input:

20

output:

1646

result:

ok 1 number(s): "1646"

Test #4:

score: 0
Accepted
time: 0ms
memory: 1604kb

input:

27

output:

3862

result:

ok 1 number(s): "3862"

Test #5:

score: 0
Accepted
time: 0ms
memory: 1576kb

input:

37

output:

9571

result:

ok 1 number(s): "9571"

Test #6:

score: 0
Accepted
time: 0ms
memory: 1596kb

input:

100

output:

175028

result:

ok 1 number(s): "175028"

Test #7:

score: 0
Accepted
time: 0ms
memory: 1608kb

input:

123

output:

322744

result:

ok 1 number(s): "322744"

Test #8:

score: 0
Accepted
time: 0ms
memory: 1632kb

input:

2548

output:

765669726

result:

ok 1 number(s): "765669726"

Test #9:

score: 0
Accepted
time: 0ms
memory: 1572kb

input:

12448

output:

159637196

result:

ok 1 number(s): "159637196"

Test #10:

score: 0
Accepted
time: 0ms
memory: 1648kb

input:

65535

output:

120089112

result:

ok 1 number(s): "120089112"

Test #11:

score: 0
Accepted
time: 0ms
memory: 1612kb

input:

102458

output:

475774506

result:

ok 1 number(s): "475774506"

Test #12:

score: 0
Accepted
time: 0ms
memory: 1600kb

input:

222333

output:

64337543

result:

ok 1 number(s): "64337543"

Test #13:

score: 0
Accepted
time: 0ms
memory: 1644kb

input:

485174

output:

312492357

result:

ok 1 number(s): "312492357"

Test #14:

score: 0
Accepted
time: 0ms
memory: 1536kb

input:

685479

output:

35530508

result:

ok 1 number(s): "35530508"

Test #15:

score: 0
Accepted
time: 0ms
memory: 1536kb

input:

1025481

output:

921523794

result:

ok 1 number(s): "921523794"

Test #16:

score: 0
Accepted
time: 0ms
memory: 1528kb

input:

9999999

output:

732610409

result:

ok 1 number(s): "732610409"

Test #17:

score: 0
Accepted
time: 0ms
memory: 1612kb

input:

7458658

output:

825346623

result:

ok 1 number(s): "825346623"

Test #18:

score: 0
Accepted
time: 0ms
memory: 1648kb

input:

5268475

output:

30938162

result:

ok 1 number(s): "30938162"

Test #19:

score: 0
Accepted
time: 0ms
memory: 1536kb

input:

2658478

output:

780038100

result:

ok 1 number(s): "780038100"

Test #20:

score: 0
Accepted
time: 0ms
memory: 1548kb

input:

10000000

output:

679483439

result:

ok 1 number(s): "679483439"

Test #21:

score: 0
Accepted
time: 0ms
memory: 1576kb

input:

100000000

output:

498142384

result:

ok 1 number(s): "498142384"

Test #22:

score: 0
Accepted
time: 0ms
memory: 1536kb

input:

1000000000

output:

69187994

result:

ok 1 number(s): "69187994"

Test #23:

score: 0
Accepted
time: 1ms
memory: 1540kb

input:

10000000000

output:

23566211

result:

ok 1 number(s): "23566211"

Test #24:

score: 0
Accepted
time: 3ms
memory: 1612kb

input:

100000000000

output:

247411531

result:

ok 1 number(s): "247411531"

Test #25:

score: 0
Accepted
time: 11ms
memory: 1588kb

input:

1000000000000

output:

434484365

result:

ok 1 number(s): "434484365"

Test #26:

score: 0
Accepted
time: 7ms
memory: 1644kb

input:

487456215487

output:

219915839

result:

ok 1 number(s): "219915839"

Test #27:

score: 0
Accepted
time: 4ms
memory: 1572kb

input:

123456654321

output:

873090152

result:

ok 1 number(s): "873090152"

Test #28:

score: 0
Accepted
time: 10ms
memory: 1528kb

input:

485623875512

output:

905855726

result:

ok 1 number(s): "905855726"

Test #29:

score: 0
Accepted
time: 8ms
memory: 1528kb

input:

598745632254

output:

548362077

result:

ok 1 number(s): "548362077"

Test #30:

score: 0
Accepted
time: 7ms
memory: 1612kb

input:

451518115487

output:

856104478

result:

ok 1 number(s): "856104478"