08-14-25
This commit is contained in:
25
Luogu/P1007 独木桥.cpp
Normal file
25
Luogu/P1007 独木桥.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
int main(){
|
||||||
|
int length, n;
|
||||||
|
int tmp;
|
||||||
|
int js;
|
||||||
|
vector<int> ma, mi;
|
||||||
|
cin >> length >> n;
|
||||||
|
for(int i = 0;i < n; i++){
|
||||||
|
cin >> tmp;
|
||||||
|
js = max(length - tmp + 1, tmp);
|
||||||
|
ma.push_back(js);
|
||||||
|
js = min(length - tmp + 1, tmp);
|
||||||
|
mi.push_back(js);
|
||||||
|
}
|
||||||
|
int smax = 0;
|
||||||
|
int smax2 = 0;
|
||||||
|
for(int i = 0;i < n; i++){
|
||||||
|
if(ma.at(i) > smax) smax = ma[i];
|
||||||
|
if(mi[i] > smax2) smax2 = mi[i];
|
||||||
|
}
|
||||||
|
cout << smax2 << " " << smax;
|
||||||
|
return 0;
|
||||||
|
}
|
19
Luogu/P1011 [NOIP 1998 提高组] 车站.cpp
Normal file
19
Luogu/P1011 [NOIP 1998 提高组] 车站.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
int main(){
|
||||||
|
vector<int> feb;
|
||||||
|
int n, a, m, x;
|
||||||
|
cin >> a >> n >> m >> x;
|
||||||
|
feb.reserve(n);
|
||||||
|
feb.push_back(1);feb.push_back(1);
|
||||||
|
for(int i = 2; i < n; i++){
|
||||||
|
feb[i] = feb[i - 1] + feb[i - 2];
|
||||||
|
}
|
||||||
|
int b = (m - (feb[n - 4] + 1) * a) / (feb[n - 3] - 1);
|
||||||
|
int out = (feb[x - 3] + 1) * a + (feb[x - 2] - 1) * b;
|
||||||
|
cout << out << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//5 7 32 4
|
||||||
|
|
@@ -1,31 +1,27 @@
|
|||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
int main(){
|
|
||||||
char a[21][11];
|
|
||||||
char sum[220]="";
|
|
||||||
int n;
|
|
||||||
cin>>n;
|
|
||||||
|
|
||||||
for(int i=0;i<n;i++){
|
struct cmp{
|
||||||
cin>>a[i];
|
bool operator()(const string& a, const string& b){
|
||||||
|
return a + b > b + a;
|
||||||
}
|
}
|
||||||
int js=1;
|
};
|
||||||
char tmp[11]="";
|
|
||||||
while(js!=0){
|
int main(){
|
||||||
js=0;
|
set<string, cmp> a;
|
||||||
for(int i=0;i<n-1;i++){
|
int n;
|
||||||
if(strcmp(a[i],a[i+1])<0){
|
cin >> n;
|
||||||
strcpy(tmp,a[i+1]);
|
string tmp;
|
||||||
strcpy(a[i+1],a[i]);
|
for(int i = 0;i < n; i++){
|
||||||
strcpy(a[i],tmp);
|
cin >> tmp;
|
||||||
js++;
|
a.emplace(tmp);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for(int i=0;i<n;i++){
|
for(string x : a){
|
||||||
strcat(sum,a[i]);
|
cout << x ;
|
||||||
}
|
}
|
||||||
cout<<sum<<endl;
|
cout << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
52
Luogu/P1015 [NOIP 1999 普及组] 回文数.cpp
Normal file
52
Luogu/P1015 [NOIP 1999 普及组] 回文数.cpp
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int charToInt(char c) {
|
||||||
|
if (c >= '0' && c <= '9') return c - '0';
|
||||||
|
if (c >= 'A' && c <= 'Z') return c - 'A' + 10;
|
||||||
|
if (c >= 'a' && c <= 'z') return c - 'a' + 10;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char intToChar(int x) {
|
||||||
|
if (x < 10) return '0' + x;
|
||||||
|
return 'A' + (x - 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
string add(const string& a, int jz) {
|
||||||
|
string b(a);
|
||||||
|
reverse(b.begin(), b.end());
|
||||||
|
string tmp(a.size() + 1, '0');
|
||||||
|
int carry = 0;
|
||||||
|
for (size_t i = 0; i < a.size(); i++) {
|
||||||
|
int ia = charToInt(a[i]);
|
||||||
|
int ib = charToInt(b[i]);
|
||||||
|
int sum = ia + ib + carry;
|
||||||
|
carry = sum / jz;
|
||||||
|
tmp[i] = intToChar(sum % jz);
|
||||||
|
}
|
||||||
|
if (carry > 0) tmp[a.size()] = intToChar(carry);
|
||||||
|
else tmp.pop_back();
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool check(const string& x) {
|
||||||
|
return equal(x.begin(), x.begin() + x.size()/2, x.rbegin());
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
int jz;
|
||||||
|
string n;
|
||||||
|
cin >> jz >> n;
|
||||||
|
for (int i = 0; i <= 30; i++) {
|
||||||
|
if (check(n)) {
|
||||||
|
cout << "STEP=" << i << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
n = add(n, jz);
|
||||||
|
}
|
||||||
|
cout << "Impossible!" << endl;
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user