Question number | topic |
---|---|
T1 | Straight line on the plane |
T2 | Interesting water pipe |
T3 | Homework Questions for Little C |
T4 | Rent a car for a spring outing |
T5 | Row numbers |
Score | 185/205 |
T1
Ideas
Not made.
T2
Ideas
This question is a dichotomy, it can be done O (log 2 k) O(\log_2{k})O(log2k ) .
We can start fromk = 1 k=1k=In the case of 1 , start pushing the formula.
From 1 ☞ k − 1 ~1☞k-1 1☞k−1 two points amid midm i d ,mid midcan be obtained from thesum formula of arithmetic sequencemid 的贡献是:
( m i d ∗ k ) − ( m i d − 1 ) − ( m i d − 1 ) ∗ m i d 2 (mid*k)-(mid-1)-\frac{(mid-1)*mid}{2} (mid∗k)−(mid−1)−2(mid−1)∗mid
For >= n >= n>=Just maintain the answer for n .
Code:
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
long long n,k,js,ans=-1;
int main()
{
cin>>n>>k;
if(n==1)
{
cout<<0;
return 0;
}
if(n<=k)
{
cout<<1;
return 0;
}
long long l=1,r=k-1,mid=0;
while(l<=r)
{
mid=(l+r)/2;
js=(mid*k)-(mid-1)-(mid-1)*mid/2;
if(js>=n)
r=mid-1,ans=mid;
else
l=mid+1;
}
cout<<ans;
return 0;
}
T3
Ideas
Not made.
T4
Ideas
Not made
T5
Ideas
For game theory , take the second largest of each row.
For specific ideas, please see the first problem solution of luogu P1199 Three Kingdoms Game
Code
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n,a[1010][1010],ans;
int main()
{
cin>>n;
for(int i=1; i<n; i++)
for(int j=i+1; j<=n; j++)
cin>>a[i][j],a[j][i]=a[i][j];
for(int i=1; i<=n; i++)
{
sort(a[i]+1,a[i]+1+n);
ans=max(ans,a[i][n-1]);
}
cout<<1<<endl<<ans;
return 0;
}