A. Paper Airplanes
Simple mathematical simulation problem.
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
ll K,n,s,p;
int main () {
scanf ("%i64d%i64d%i64d%i64d", &k,&n,&s,&p);
ll Each=ceil (1.0*N/S);
ll Tot=each*k;
ll Ans=1ll*ceil (1.0*tot/p);
cout<<ans<<endl;
return 0;
}
B. Battleship
In a grid diagram of a n∗n n∗n n*n, some points have obstacles. A ship can be placed in an empty mine, and the Captain K K K is required to have a continuous K-seat.
The squares that are covered by the maximum scheme.
n,k<=100 N, K <= n,k
The area where a ship is covered is obviously a space, and these lattice answers are added 1 1 1.
Then we can think of the barrier and the space as 1 0 to get the prefix and can quickly obtain this place can put the boat.
The problem becomes multiple interval plus, the last query maximum value. Differential.
#include <bits/stdc++.h> using namespace std;
const int maxn=105;
int mmap[maxn][maxn],sum[maxn][maxn],cf[maxn][maxn],ans[maxn][maxn],ans2[maxn][maxn],h=1,l=1,ansp=0,n,k;
Char S[MAXN];
int main () {scanf ("%d%d", &n,&k);
for (int i=1;i<=n;i++) {scanf ("%s", s);
for (int j=0;j<n;j++) {if (s[j]== ' # ') mmap[i][j+1]=1;
else mmap[i][j+1]=0;
}} for (int i=1;i<=n;i++) {for (int j=1;j<=n;j++) {sum[i][j]=sum[i][j-1]+mmap[i][j];
}} for (int i=1;i<=n;i++) {for (int j=1;j<=n;j++) {if (j+k-1>n) break;
if (sum[i][j-1]==sum[i][j+k-1]) cf[i][j]++,cf[i][j+k]--;
}} for (int i=1;i<=n;i++) {for (int j=1;j<=n;j++) {ans[i][j]=ans[i][j-1]+cf[i][j];
}} memset (Sum,0,sizeof (sum));
memset (cf,0,sizeof (CF)); for (int i=1;i<=n;i++) {for (int j=1;j<=n;j++) {sum[j][i]=Sum[j-1][i]+mmap[j][i];
}} for (int i=1;i<=n;i++) {for (int j=1;j<=n;j++) {if (j+k-1>n) break;
if (Sum[j-1][i]==sum[j+k-1][i]) cf[j][i]++,cf[j+k][i]--;
}} for (int i=1;i<=n;i++) {for (int j=1;j<=n;j++) {ans2[j][i]=ans2[j-1][i]+cf[j][i];
}} for (int i=1;i<=n;i++) {for (int j=1;j<=n;j++) {if (ANS[I][J]+ANS2[I][J]>ANSP) {
Ansp=ans[i][j]+ans2[i][j],h=i,l=j;
}}} cout<
C. Greedy Arkady
K K K children surrounded by a circle of n n n Sugar in the order of 1−k−1 1−k−1 1-k-1 in turn to sugar. Each time x x x block of sugar is less than x x x sugar is discarded.
Specifies that x<=m x <= M x and no children have a greater number of sugars than D (lap number). Ask 1 1 1th children to get the maximum number of sugars.
(2≤n≤1018,2≤k≤n,1≤m≤n,1≤d≤min (n,1000), m⋅d⋅k≥n) (2≤n≤10 18, 2≤k≤n, 1≤m≤n, 1≤d≤m i n (n, +), m⋅d⋅k≥n) (2≤n≤10^{18}, 2≤k≤n, 1≤m≤n, 1≤d≤min (n,1000), m⋅d⋅k≥n)
Find d very small.
If D is known, we can be greedy to find out