QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#562023 | #8190. Jaw-Dropping Set | Afterlife# | AC ✓ | 18ms | 3716kb | C++20 | 489b | 2024-09-13 14:21:40 | 2024-09-13 14:21:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
inline ll sqr(int x){
return 1LL*x*x;
}
void Solve(){
cin>>n;
if(n%2==0)--n;
int m=n/3;
ll ans=sqr((n+1)/2);
ll t=1;
while(m){
if(m%2==0)--m;
ans+=sqr((m+1)/2)*t;
m/=3;
t<<=1;
}
cout<<ans<<'\n';
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin>>T;
while(T--)Solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
7 1 2 3 4 5 6 7
output:
1 1 5 5 10 10 17
result:
ok 7 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
12 8 9 10 11 12 13 14 15 16 17 18 19
output:
17 31 31 42 42 55 55 75 75 92 92 111
result:
ok 12 numbers
Test #3:
score: 0
Accepted
time: 12ms
memory: 3708kb
input:
100000 1 2 3 4 5 6 7 8 9 10 12 14 16 18 24 26 27 28 30 32 36 42 44 50 54 64 72 76 78 80 81 82 84 87 90 108 128 138 141 148 162 216 234 240 242 243 244 246 252 256 270 324 346 391 466 486 512 568 581 648 702 720 726 728 729 730 732 738 756 787 810 967 972 1024 1143 1458 1944 1948 2009 2048 2063 2106 ...
output:
1 1 5 5 10 10 17 17 31 31 42 55 75 92 162 187 233 233 262 293 372 502 545 711 832 1181 1476 1649 1726 1805 1951 1951 2034 2235 2324 3336 4659 5462 5789 6273 7496 13320 15620 16410 16651 17105 17105 17350 18180 18773 20848 30000 34207 43853 62137 67480 74741 92357 96766 119952 140752 148020 150430 15...
result:
ok 100000 numbers
Test #4:
score: 0
Accepted
time: 18ms
memory: 3716kb
input:
100000 999871466 999866932 999980486 999914188 999831578 999833026 999944506 999827606 999838686 999976774 999813164 999994946 999807682 999841056 999832968 999913784 999925780 999906796 999812672 999890922 999831530 999874568 999950564 999885552 999983336 999968546 999918360 999936564 999973810 999...
output:
285640842333511147 285638251976446343 285703134723221387 285665252416444705 285618052724425771 285618880041538815 285682575979069227 285615783147825789 285622113774079542 285701013809241835 285607532273116489 285711397713340359 285604400272258011 285623467653271318 285618846661197588 285665021481577...
result:
ok 100000 numbers
Test #5:
score: 0
Accepted
time: 11ms
memory: 3564kb
input:
100000 128535 133069 19515 85813 168423 166975 55495 172395 161315 23227 186837 5055 192319 158945 167033 86217 74221 93205 187329 109079 168471 125433 49437 114449 16665 31455 81641 63437 26191 150035 153779 92487 151725 119235 134919 20651 169549 22551 166725 144141 18705 188631 18937 7937 157135 ...
output:
4720429291 5059299743 108819329 2103999379 8104795047 7965968513 879940875 8491579977 7435098164 154148453 9973856113 7304339 10567659557 7218209534 7971541526 2123882873 1573953511 2482086365 10026432123 3399550056 8109424257 4495365907 698332507 3742487446 79361441 282717677 1904412970 1149827918 ...
result:
ok 100000 numbers
Test #6:
score: 0
Accepted
time: 12ms
memory: 3560kb
input:
100000 999999999 1000000000 999999999 1000000000 999999999 999999999 999999999 999999999 999999999 999999999 1000000000 999999999 999999999 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 999999999 999999999 1000000000 1000000000 1000000000 1000000000 999999999 1000000000 100000000...
output:
285714286056293709 285714286056293709 285714286056293709 285714286056293709 285714286056293709 285714286056293709 285714286056293709 285714286056293709 285714286056293709 285714286056293709 285714286056293709 285714286056293709 285714286056293709 285714286056293709 285714286056293709 285714286056293...
result:
ok 100000 numbers