ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#204403 | #3603. 函数求和 | smallstone | 100 | 45481ms | 169828kb | C++11 | 1.3kb | 2024-05-19 11:40:54 | 2024-05-19 12:36:43 |
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
//using LL = __int128
#define N 11111111
#define M 1111111
#define mod 1000000007ll
ll t, n, a, b, sum;
int f[N], g[N], pme[M], pe[N], cnt[N], pos;
bool npme[N];
void init2(){
n = 10000000;
for(int i = 2 ; i <= n ; i++){
if(!npme[i]){
pme[++pos] = i;
pe[i] = i;
}
cnt[i] = pos;
for(int j = 1 ; pme[j] * i <= n && j <= pos ; j++){
npme[i * pme[j]] = true;
if(i % pme[j] == 0){
pe[i * pme[j]] = pe[i] * pme[j];
break;
}
else
pe[i * pme[j]] = pme[j];
}
}
}
void init(){
for(int i = 2 ; i <= n ; i++){
if(!npme[i]){
//pme[++pos] = i;
//pe[i] = i;
f[i] = (a + b * i) % mod;
//f[i] %= mod;
g[i] = 1;
}
for(int j = 1 ; pme[j] * i <= n && j <= cnt[i] ; j++){
//npme[i * pme[j]] = true;
if(i % pme[j] == 0){
//pe[i * pme[j]] = pe[i] * pme[j];
f[i * pme[j]] = 1ll * g[i] * (f[pe[i]] + a) % mod;
g[i * pme[j]] = g[i];
break;
}
else{
//pe[i * pme[j]] = pme[j];
f[i * pme[j]] = 1ll * f[i] * f[pme[j]] % mod;
g[i * pme[j]] = f[i];
}
}
sum = (f[i] + sum) % mod;
}
}
int main(){
cin >> t;
init2();
while(t--){
pos = 0;
sum = 1;
cin >> n >> a >> b;
init();
cout << sum << "\n";
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 683ms
memory: 99516kb
input:
30 1000000 167959138 481199251 1000000 336470887 634074577 1000000 642802745 740396294 1000000 77338...
output:
825041836 100884595 213454495 64549852 686751510 752815302 988374132 343491237 293721311 647153869 7...
result:
ok 30 lines
Test #2:
score: 10
Accepted
time: 457ms
memory: 99516kb
input:
30 1000000 641009858 54748095 1000000 75475633 804928247 1000000 476927807 284875071 1000000 5031588...
output:
292450758 119114683 606527410 131436814 324316270 548009072 854362888 726652511 500857354 349511966 ...
result:
ok 30 lines
Test #3:
score: 10
Accepted
time: 457ms
memory: 99516kb
input:
30 1000000 524125986 923264236 1000000 374288890 535590428 1000000 751244357 124321144 1000000 23293...
output:
458800982 440409370 743119898 133039593 624663061 469806058 589757267 225425438 176748704 430581699 ...
result:
ok 30 lines
Test #4:
score: 10
Accepted
time: 6546ms
memory: 169828kb
input:
30 10000000 0 702209410 10000000 0 496813080 10000000 0 673102148 10000000 0 561219906 10000000 0 73...
output:
53084534 38542915 118201744 419481485 572882497 32514206 340162033 454113055 992244675 964965966 749...
result:
ok 30 lines
Test #5:
score: 10
Accepted
time: 6837ms
memory: 169824kb
input:
30 10000000 0 585325538 10000000 0 365329220 10000000 0 412106894 10000000 0 291882088 10000000 0 56...
output:
940722692 88380261 51909689 745147634 222039731 540300283 615815948 287090665 944004269 103232302 58...
result:
ok 30 lines
Test #6:
score: 10
Accepted
time: 6007ms
memory: 169824kb
input:
30 10000000 0 58376258 10000000 0 643910769 10000000 0 5887447 10000000 0 757703053 10000000 0 54406...
output:
772721356 130729136 743902231 904638637 501118478 547111440 626587951 342855784 544619185 81610310 1...
result:
ok 30 lines
Test #7:
score: 10
Accepted
time: 6284ms
memory: 169828kb
input:
30 10000000 941492386 72235421 10000000 449924897 783332531 10000000 378192987 592684635 10000000 14...
output:
98013335 512482535 418204063 287894433 282103676 585040561 157954730 933082695 562282715 990985994 6...
result:
ok 30 lines
Test #8:
score: 10
Accepted
time: 6241ms
memory: 169824kb
input:
30 10000000 824608514 940751562 10000000 43705450 513994712 10000000 652509536 432130708 10000000 31...
output:
604274564 352170402 623751914 669414785 750946298 478293516 886076834 99969221 479431914 219919855 1...
result:
ok 30 lines
Test #9:
score: 10
Accepted
time: 6059ms
memory: 169828kb
input:
30 10000000 2691938 514300406 10000000 782710196 539624190 10000000 631858790 976609485 10000000 752...
output:
452821050 477282094 778221272 273359360 418840784 208386336 879731396 700892638 147697661 148502894 ...
result:
ok 30 lines
Test #10:
score: 10
Accepted
time: 5910ms
memory: 169828kb
input:
30 10000000 802030517 598196517 10000000 640274070 983359970 10000000 71550120 96204861 10000000 799...
output:
761153709 785024096 507790375 446298599 967931807 236711001 151729697 27331720 233850630 395344900 4...
result:
ok 30 lines
Extra Test:
score: 0
Extra Test Passed