QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#89354 | #5822. 城市建设 | zhyz | 60 | 892ms | 3536kb | C++14 | 508b | 2023-03-19 20:38:28 | 2023-03-19 20:38:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL f(LL n,LL k)
{
if(k==1) return n*n/4;
LL p = n/k, r = n%k;
LL tol = p*p/4*(k-r)+(p+1)*(p+1)/4*r;
if(r==0) tol += n-p/2*2-1;
else if(r==1) tol += n-p/2-(p+1)/2-1;
else tol += n-(p+1)/2*2-1;
return tol;
}
int main()
{
LL n,c;
cin>>n>>c;
LL ans = n*n/4+c;
if(n>=5e8) n /= 10;
for(int k=2;k<=n;k++)
ans = min(ans,f(n,k)+c*k);
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 5
Accepted
time: 2ms
memory: 3352kb
input:
14 7
output:
45
result:
ok single line: '45'
Test #2:
score: 5
Accepted
time: 2ms
memory: 3536kb
input:
15 9
output:
53
result:
ok single line: '53'
Test #3:
score: 5
Accepted
time: 2ms
memory: 3516kb
input:
15 32
output:
88
result:
ok single line: '88'
Test #4:
score: 5
Accepted
time: 0ms
memory: 3480kb
input:
18 47
output:
128
result:
ok single line: '128'
Test #5:
score: 5
Accepted
time: 2ms
memory: 3304kb
input:
691 13
output:
3152
result:
ok single line: '3152'
Test #6:
score: 5
Accepted
time: 2ms
memory: 3396kb
input:
723 381
output:
14800
result:
ok single line: '14800'
Test #7:
score: 5
Accepted
time: 0ms
memory: 3392kb
input:
530 4577
output:
36261
result:
ok single line: '36261'
Test #8:
score: 5
Accepted
time: 0ms
memory: 3400kb
input:
873 71661
output:
239024
result:
ok single line: '239024'
Test #9:
score: 5
Accepted
time: 2ms
memory: 3348kb
input:
50512 6380
output:
4084971
result:
ok single line: '4084971'
Test #10:
score: 5
Accepted
time: 3ms
memory: 3468kb
input:
94371 8943
output:
9018507
result:
ok single line: '9018507'
Test #11:
score: 5
Accepted
time: 0ms
memory: 3396kb
input:
51969 2391
output:
2593001
result:
ok single line: '2593001'
Test #12:
score: 5
Accepted
time: 3ms
memory: 3356kb
input:
90967 8394
output:
8424956
result:
ok single line: '8424956'
Test #13:
score: 0
Wrong Answer
time: 892ms
memory: 3308kb
input:
903367404 61
output:
794963296
result:
wrong answer 1st lines differ - expected: '7949633140', found: '794963296'
Test #14:
score: 0
Wrong Answer
time: 582ms
memory: 3480kb
input:
619459664 4190
output:
4071626590
result:
wrong answer 1st lines differ - expected: '40716267253', found: '4071626590'
Test #15:
score: 0
Wrong Answer
time: 698ms
memory: 3352kb
input:
714829312 304390
output:
39509710321
result:
wrong answer 1st lines differ - expected: '395097112253', found: '39509710321'
Test #16:
score: 0
Wrong Answer
time: 746ms
memory: 3516kb
input:
760183494 45248537
output:
511428883817
result:
wrong answer 1st lines differ - expected: '5114288962225', found: '511428883817'
Test #17:
score: 0
Wrong Answer
time: 479ms
memory: 3304kb
input:
500350887 499
output:
1167485344
result:
wrong answer 1st lines differ - expected: '11674853991', found: '1167485344'
Test #18:
score: 0
Wrong Answer
time: 824ms
memory: 3308kb
input:
837064072 96455
output:
26080543471
result:
wrong answer 1st lines differ - expected: '260805440727', found: '26080543471'
Test #19:
score: 0
Wrong Answer
time: 744ms
memory: 3352kb
input:
784256648 6177252
output:
194998175712
result:
wrong answer 1st lines differ - expected: '1949981815499', found: '194998175712'
Test #20:
score: 0
Wrong Answer
time: 623ms
memory: 3344kb
input:
650371022 480071734
output:
1425062982261
result:
wrong answer 1st lines differ - expected: '14250630194974', found: '1425062982261'