QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#505082 | #9133. Function with Many Maximums | ucup-team2307# | AC ✓ | 21ms | 9236kb | C++20 | 1.2kb | 2024-08-04 19:35:20 | 2024-08-04 19:35:20 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define fi first
#define se second
#define pb push_back
typedef long double ld;
#define double ld
vector<int> ans;
void solve(int k, int a, int n)
{
if (a > 1e12)
exit(4);
if (n == 0)
{
while (k > 0)
{
a++;
ans.pb(a);
k--;
}
return;
}
if (k-1 == 0)
exit(1);
int rem = ((-2*a-k*a)%(k-1) + (k-1))%(k-1);
int b = a-a%(k-1)+rem;
while (b <= a) b += (k-1);
int c = (2*a+k*a+b)/(k-1);
if (c*(k-1) != (2*a+k*a+b))
exit(2);
ans.pb(b);
ans.pb(c);
if (c <= b)
exit(3);
solve(k-2, c, n-1);
}
int f(int x)
{
int s = 0;
for (int i : ans)
if (x <= i) s += x+i;
return s;
}
signed main()
{
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
cout<<fixed<<setprecision(20);
int K;
cin>>K;
int A = 50e9;
ans.pb(A);
solve(3e5+100, A, K);
cout<<ans.size()<<"\n";
for (int i : ans)
cout<<i<<" ";
cout<<"\n";
// for (int i =0; i<20; i++)
// cout<<f(ans[i])<<endl;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 15ms
memory: 8592kb
input:
4
output:
300101 50000000000 50000078253 50000666447 50000947376 50001332908 50001516306 50001999382 50002085145 50002665869 50002665870 50002665871 50002665872 50002665873 50002665874 50002665875 50002665876 50002665877 50002665878 50002665879 50002665880 50002665881 50002665882 50002665883 50002665884 50002...
result:
ok n=300101, max_a=50002965961, max_num=5 >= 4
Test #2:
score: 0
Accepted
time: 21ms
memory: 9236kb
input:
100000
output:
300101 50000000000 50000078253 50000666447 50000947376 50001332908 50001516306 50001999382 50002085145 50002665869 50002953984 50003332370 50003522636 50003998884 50004091197 50004665411 50004959752 50005331952 50005528126 50005998506 50006096409 50006665073 50006964680 50007331654 50007532776 50007...
result:
ok n=300101, max_a=449389147397, max_num=100001 >= 100000
Extra Test:
score: 0
Extra Test Passed