12-6 be a weak chicken from 0

Some related to permutation: functions and stl containers

1. Sort (first address, last address, sorting mode cmp);

cmp is user-defined, usually structured, and vector is packaged and taken away;

2.next_permutation starts from the second sequential full sort. If you want to print all, it is used in combination with the do while statement;

3.set automatic sorting and de duplication (there are also sorting only without de duplication and de duplication only without sorting)

4.map automatic sorting and de duplication (mainly reflects a mapping relationship, which can associate two data, such as the relationship between the subscript of the array and the number stored in the array);

Title Description

This question is a blank filling question. You only need to calculate the result and use the output statement in the code to output the filled result.

hold   eleven  ~  ninety-nine   this   ninety-nine   A number is divided into two groups, with a multiplication sign inserted in the middle. Sometimes, their product only contains   eleven  ~  ninety-nine   this   ninety-nine   A number, and each number only appears   eleven   Times.

For example:

984672 * 351 = 345619872
98751 * 3462 = 341875962
9 * 87146325 = 784316925

There are many formulas that conform to this law. Please calculate the maximum product of all these formulas?

Note that what needs to be output is an integer, indicating the largest product. Only the product is output, not the whole formula.

Operating limits

  • Maximum running time: 1s
  • Maximum operating memory: 128M


#include <bits/stdc++.h>
using namespace std;
bool check1(long long num){
		if(num%10==0) return false;
	return se.size()==9;//Very clever, using the number after weight removal;
int main(){
	long long ans=0;
	int num1[9]={1,2,3,4,5,6,7,8,9};
	do{for(int i=1;i<9;i++){
		long long num_2=0;
		long long num_1=0;
		for(int j=0;j<i;j++){num_1+=num1[j]*pow(10,i-j-1);}
		for(int j=i;j<9;j++){num_2+=num1[j]*pow(10,9-j-1);
	return 0;
}//Multiple choice questions, directly play the table, hee hee

Title Description

Xiao Ming maintains a programmer forum. Now he has collected a "like" log, which has   NN   Rows. The format of each row is:

ts\ idts id

Indicates in   tsts   Time number   idid   Your post received a "like".

Now Xiao Ming wants to count which posts have been "hot posts". If a post has been in any length of   DD   Not less than   KK   A praise, Xiao Ming thought this post was a "hot post".

Specifically, if there is a time t that satisfies the post at   [T,T+D)[T,T+D)   Within this period of time (pay attention to the left closed right open section), the received data shall not be less than   KK   A praise, the post was once a "hot post".

Given the log, please help Xiao Ming count all the post numbers that were once "hot posts".

Enter description

Input format:

The first line contains three integers   N,D,KN,D,K.

Each of the following N lines contains two integers ts and id.

Where, 1 \leq K \leq N \leq 10^5, 0 \leq ts \leq 10^5,0 \leq id \leq 10^51 ≤ K ≤ N ≤ 105,0 ≤ ts ≤ 105,0 ≤ id ≤ 105.

Output description

Output hot posts from small to large   Idid. Each   idid   a line.

Input and output samples



7 10 2
0 1
0 10
10 10
10 1
9 1
100 3
100 3



Operating limits

  • Maximum running time: 1s
  • Maximum operating memory: 256M

This involves the ruler taking method!

Two operations:

1. Take ts as the measurement length to find the two endpoints of left closing and right opening;

2. Output the id name after de duplication;

#include <bits/stdc++.h>
using namespace std;
struct xixi{
	int ts;
	int id;
bool cmp(xixi aa,xixi bb){
	return aa.ts<bb.ts;
long long n,d,k;
int main(){
	for(int i=0;i<n;i++) cin>>ts_id[i].ts>>ts_id[i].id;
	for(int l=0;l<n;l++) {
		for(int r=l;ts_id[r].ts<ts_id[l].ts+d&&r<n;r++){

	for(auto it=ans.begin();it!=ans.end();it++){


Tags: C++ Algorithm

Posted on Mon, 06 Dec 2021 16:26:27 -0500 by manianprasanna