Rnin

1554

Rnin
8个月前

Rnin
8个月前

Rnin
8个月前

Rnin
8个月前

### 代码


#include <string>
#include <iostream>
using namespace std;

const int N = 100000;
int idx, e[N+5], fr[N+5], ne[N+5];

void init()
{
fr[1]=0;
ne[0]=1;
idx=2;
}

void insertL(int x)
{
fr[idx]=0;
ne[idx]=ne[0];
ne[0]=idx;
fr[ne[idx]]=idx;
e[idx++]=x;
}

void insertR(int x)
{
ne[idx]=1;
fr[idx]=fr[1];
ne[fr[idx]]=idx;
fr[1]=idx;
e[idx++]=x;
}

void insertIL(int x, int k)
{
fr[idx]=fr[k];
ne[idx]=k;
ne[fr[idx]]=idx;
fr[k]=idx;
e[idx++]=x;
}

void insertIR(int x, int k)
{
ne[idx]=ne[k];
fr[idx]=k;
fr[ne[idx]]=idx;
ne[k]=idx;
e[idx++]=x;
}

void delK(int k)
{
ne[fr[k]]=ne[k];
fr[ne[k]]=fr[k];
}

int main() {
int m;
init();

cin >> m;
while (m--) {
string s;
int oper_one, oper_two;
cin >> s;
if (s == "L") {
cin >> oper_one;
insertL(oper_one);
}
else if (s == "R") {
cin >> oper_one;
insertR(oper_one);
}
else if (s == "D") {
cin >> oper_two;
delK(oper_two+1);
}
else if (s == "IL") {
cin >> oper_two >> oper_one;
insertIL(oper_one, oper_two+1);
}
else if (s == "IR") {
cin >> oper_two >> oper_one;
insertIR(oper_one, oper_two+1);
}
}

for (int index=ne[0]; index!=1; index=ne[index]) cout << e[index] << " ";

return 0;
}



Rnin
8个月前


#include <iostream>
using namespace std;

const int N = 100005;

}

void insertK(int x, int k) {
e[idx]=x, ne[idx]=ne[k], ne[k]=idx++;
}

void delK(int k) {
ne[k]=ne[ne[k]];
}

int main() {
char c;
int m, oper_one, oper_two;
cin >> m;
while (m--) {
cin >> c;
if (c == 'H') {
cin >> oper_one;
}
else if (c == 'D') {
cin >> oper_two;
delK(oper_two-1);
}
else if (c == 'I') {
cin >> oper_two >> oper_one;
insertK(oper_one, oper_two-1);
}
}

for (int index=head; index!=-1; index=ne[index]) cout << e[index] << " ";

return 0;
}



Rnin
8个月前

### 基本思路

#### C++ 代码


#include <iostream>

#define Ull unsigned long long

using namespace std;

Ull quickMul( Ull a, Ull b, Ull p )
{
Ull res=0, base=b;
while ( a )
{
if ( a & 1 ) res = (res+base)%p;
base = (base+base)%p;
a >>= 1;
}
return res;

}

int main()
{
Ull a, b, p, s;
cin >> a >> b >> p;
s = quickMul(a, b, p);
cout << s << endl;
return 0;

}



Rnin
8个月前

#include <iostream>

#define Ull unsigned long long

using namespace std;

Ull quickMul( Ull a, Ull b, Ull p )
{
Ull res=0, base=b;
while ( a )
{
if ( a & 1 ) res = (res+base)%p;
base = (base+base)%p;
a >>= 1;
}
return res;

}

int main()
{
Ull a, b, p, s;
cin >> a >> b >> p;
s = quickMul(a, b, p);
cout << s << endl;
return 0;

}



Rnin
8个月前

#include <iostream>
#define LL long long
using namespace std;

LL quickPow( LL a, LL b, LL p )
{
LL res=1, base=a;
while ( b )
{
if ( b & 1 ) res = res*base%p;
base = base*base%p;
b >>= 1;
}
return res;

}

int main()
{
LL a, b, p, s;
cin >> a >> b >> p;
s = quickPow(a, b, p)%p;
cout << s << endl;
return 0;

}



Rnin
8个月前

#include <iostream>
#define LL long long
using namespace std;

LL quickPow( LL a, LL b, LL p )
{
LL res=1, base=a;
while ( b )
{
if ( b & 1 ) res = res*base%p;
base = base*base%p;
b >>= 1;
}
return res;

}

int main()
{
LL a, b, p, s;
cin >> a >> b >> p;
s = quickPow(a, b, p)%p;
cout << s << endl;
return 0;

}



Rnin
2020-02-23 01:26

#include <iostream>
using namespace std;

int main(){
int n, m; cin >> n >> m;
cout << n + m;
return 0;
}