#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define pb push_back
using namespace __gnu_pbds;
using namespace std;
typedef tree<long long int, null_type, less_equal<long long int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_multiset;
//ordered_multiset s3;
//ordered_multiset :: iterator it;
const ll mod=1e9+7;
const ll N=1e1;
bool sive[N];
vector<ll>prime;
vector<ll>v;
vector<ll>p;
set<ll>s;
set<ll>:: iterator it;
ll k,num,m;
long long int gcd(long long int a,long long int b)
{
long long int c;
while(a%b!=0)
{
c=b;
b=a%b;
a=c;
}
return b;
}
double cal(double x)
{
double y=sqrt(x);
return(x*x+2*y);
}
bool cheak(ll n)
{
ll b,c,a;
if(n>=k)
{
a=(((n*(n+1))/2)-((n-k)*((n-k)+1)/2));
}
else{
a=((n*(n+1))/2)+k-n;
}
ll n1=n-1;
c=num-k;
if(c<=n1)
{
b=(((n1*(n1+1))/2)-(((n1-c)*((n1-c)+1))/2));
}
else{
b=((n1*(n1+1))/2)+c-n1;
}
if(a+b<=m)
return true;
else
return false;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll i,j;
for(i=0; i<N; i++)
{
sive[i]=true;
}
sive[0]=false;
sive[1]=false;
for(i=2; i*i<=N; i++)
#include <bits/stdc++.h>
using namespace std;
struct doubleLinklist{
int val;
doubleLinklist* forward;
doubleLinklist* backward;
};
struct doubleLinklist* create(int val){
struct doubleLinklist* new_element = new doubleLinklist;
new_element->val = val;
new_element ->forward = NULL;
new_element->backward = NULL;
return new_element;
}
void insert(doubleLinklist* &first_element,int val){
struct doubleLinklist* new_element = create(val);
first_element->forward = new_element;
new_element->backward = first_element;
first_element = first_element->forward;
}
void delete_node(doubleLinklist*& head,doubleLinklist* &tail,int val){
doubleLinklist* head1 = head;
doubleLinklist* tail1 = tail;
if(head == tail){
if(head->val == val){
doubleLinklist* temp = head;
head = NULL;
tail= NULL;
delete temp;
}
}
else if(head->val == val){
doubleLinklist* temp = head;
head= head->forward;
head->backward = NULL;
delete temp;
}
else if(tail->val == val){
doubleLinklist* temp = tail;
tail= tail->backward;
tail->forward= NULL;
delete temp;
}
else {
while(head1 != tail1){
if(head1->val == val){
doubleLinklist* temp = head1;
doubleLinklist* prev = head1->backward;
doubleLinklist* next = head1->forward;
delete temp;
prev->forward = next;
next->backward = prev;
break;
}
head1= head1->forward;
}
}
}
void Print(doubleLinklist* head){
while(head){
cout<< head->val <<" ";
head= head->forward;
}
cout<<"\n";
}
int main(){
doubleLinklist * head = create(0);
doubleLinklist* tail = head;
//insert(tail,1);
delete_node(head,tail,0);
Print(head);
}
Code Highlighter Test
511 字 发布于 2023-04-27 574 次阅读
Comments NOTHING