Initiate Luogu
This commit is contained in:
63
Luogu/P1002过河卒.cpp
Normal file
63
Luogu/P1002过河卒.cpp
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main(){
|
||||||
|
int n,m,max,may;
|
||||||
|
cin>>n>>m>>may>>max;
|
||||||
|
long long a[22][22];
|
||||||
|
//reset to 0
|
||||||
|
for(int i=0;i<22;i++){
|
||||||
|
for(int j=0;j<22;j++){
|
||||||
|
a[i][j]=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i = 0; i < 22; i++){
|
||||||
|
a[0][i]=1;
|
||||||
|
a[i][0]=1;
|
||||||
|
}
|
||||||
|
a[may][max]=-1;
|
||||||
|
if((may-1)>=0&&(max-2)>=0) a[may-1][max-2]=-1;
|
||||||
|
if((may-2)>=0&&(max-1)>=0) a[may-2][max-1]=-1;
|
||||||
|
if((may-2)>=0&&(max+1)<=21) a[may-2][max+1]=-1;
|
||||||
|
if((may-1)>=0&&(max+2)<=21) a[may-1][max+2]=-1;
|
||||||
|
if((may+1)<=21&&(max+2)<=21) a[may+1][max+2]=-1;
|
||||||
|
if((may+2)<=21&&(max+1)<=21) a[may+2][max+1]=-1;
|
||||||
|
if((may+2)<=21&&(max-1)>=0) a[may+2][max-1]=-1;
|
||||||
|
if((may+1)<=21&&(max-2)>=0) a[may+1][max-2]=-1;
|
||||||
|
for(int i=0;i<22;i++){
|
||||||
|
if(a[i][0]==-1){
|
||||||
|
for(int j=i;j<22;j++){
|
||||||
|
a[j][0]=0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i=0;i<22;i++){
|
||||||
|
if(a[0][i]==-1){
|
||||||
|
for(int j=i;j<22;j++){
|
||||||
|
a[0][j]=0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i=1;i<22;i++){
|
||||||
|
for(int j=1;j<22;j++){
|
||||||
|
if(a[i][j]==-1)
|
||||||
|
continue;
|
||||||
|
if(a[i][j]!=-1&&a[i-1][j]!=-1&&a[i][j-1]!=-1)
|
||||||
|
a[i][j]=a[i-1][j]+a[i][j-1];
|
||||||
|
if(a[i][j]!=-1&&a[i-1][j]!=-1&&a[i][j-1]==-1)
|
||||||
|
a[i][j]=a[i-1][j];
|
||||||
|
if(a[i][j]!=-1&&a[i-1][j]==-1&&a[i][j-1]!=-1)
|
||||||
|
a[i][j]=a[i][j-1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout<<a[n][m]<<endl;
|
||||||
|
/*
|
||||||
|
for(int i=0;i<22;i++){
|
||||||
|
for(int j=0;j<22;j++){
|
||||||
|
cout<<a[i][j]<<" ";
|
||||||
|
}
|
||||||
|
cout<<endl;
|
||||||
|
}//*/
|
||||||
|
return 0;
|
||||||
|
}
|
51
Luogu/P1010 [NOIP1998 普及组] 幂次方.cpp
Normal file
51
Luogu/P1010 [NOIP1998 普及组] 幂次方.cpp
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
using namespace std;
|
||||||
|
string flag(int in){
|
||||||
|
if(in==15) return "2(2+2(0))+2(2)+2+2(0)";
|
||||||
|
else if(in==14) return "2(2+2(0))+2(2)+2";
|
||||||
|
else if(in==13) return "2(2+2(0))+2(2)+2(0)";
|
||||||
|
else if(in==12) return "2(2+2(0))+2(2)";
|
||||||
|
else if(in==11) return "2(2+2(0))+2+2(0)";
|
||||||
|
else if(in==10) return "2(2+2(0))+2";
|
||||||
|
else if(in==9) return "2(2+2(0))+2(0)";
|
||||||
|
else if(in==8) return "2(2+2(0))";
|
||||||
|
else if(in==7) return "2(2)+2+2(0)";
|
||||||
|
else if(in==6) return "2(2)+2";
|
||||||
|
else if(in==5) return "2(2)+2(0)";
|
||||||
|
else if(in==4) return "2(2)";
|
||||||
|
else if(in==3) return "2+2(0)";
|
||||||
|
else if(in==2) return "2";
|
||||||
|
else return "";
|
||||||
|
}
|
||||||
|
int main(){
|
||||||
|
int n;
|
||||||
|
cin>>n;
|
||||||
|
int a[16]={0},b[16]={-1},c[16]={-1},d[16]={-1};
|
||||||
|
for(int j=0;j<16;j++){
|
||||||
|
a[j]=pow(2,j);
|
||||||
|
}
|
||||||
|
int tmp=n;
|
||||||
|
int i=15,js=0;
|
||||||
|
while(tmp!=0){
|
||||||
|
if(tmp>=a[i]){
|
||||||
|
tmp-=a[i];
|
||||||
|
b[js]=i;
|
||||||
|
js++;
|
||||||
|
}
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
for(int j=0;j<js;j++){
|
||||||
|
if(b[j]!=0&&b[j]!=1) cout<<"2("<<flag(b[j])<<")";
|
||||||
|
if(b[j]==1) cout<<"2";
|
||||||
|
if(b[j]==0) cout<<"2(0)";
|
||||||
|
if(j!=(js-1)){
|
||||||
|
cout<<"+";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
31
Luogu/P1012 [NOIP 1998 提高组] 拼数.cpp
Normal file
31
Luogu/P1012 [NOIP 1998 提高组] 拼数.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include <cstring>
|
||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main(){
|
||||||
|
char a[21][11];
|
||||||
|
char sum[220]="";
|
||||||
|
int n;
|
||||||
|
cin>>n;
|
||||||
|
|
||||||
|
for(int i=0;i<n;i++){
|
||||||
|
cin>>a[i];
|
||||||
|
}
|
||||||
|
int js=1;
|
||||||
|
char tmp[11]="";
|
||||||
|
while(js!=0){
|
||||||
|
js=0;
|
||||||
|
for(int i=0;i<n-1;i++){
|
||||||
|
if(strcmp(a[i],a[i+1])<0){
|
||||||
|
strcpy(tmp,a[i+1]);
|
||||||
|
strcpy(a[i+1],a[i]);
|
||||||
|
strcpy(a[i],tmp);
|
||||||
|
js++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i=0;i<n;i++){
|
||||||
|
strcat(sum,a[i]);
|
||||||
|
}
|
||||||
|
cout<<sum<<endl;
|
||||||
|
return 0;
|
||||||
|
}
|
18
Luogu/P1035 [NOIP2002 普及组] 级数求和.cpp
Normal file
18
Luogu/P1035 [NOIP2002 普及组] 级数求和.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
double sum; // Use double for sum to handle fractions
|
||||||
|
int n, k;
|
||||||
|
cin >> k;
|
||||||
|
n = 1;
|
||||||
|
sum = 0.0;
|
||||||
|
while (sum <= k)
|
||||||
|
{
|
||||||
|
sum = sum + 1.0 / n; // Use 1.0 to ensure floating-point division
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
cout << n - 1 << endl; // n is incremented one extra time in the loop
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
17
Luogu/P1035.cpp
Normal file
17
Luogu/P1035.cpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
double sum; // Use double for sum to handle fractions
|
||||||
|
int n, k;
|
||||||
|
cin >> k;
|
||||||
|
n = 1;
|
||||||
|
sum = 0.0;
|
||||||
|
while (sum <= k)
|
||||||
|
{
|
||||||
|
sum = sum + 1.0 / n; // Use 1.0 to ensure floating-point division
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
cout << n - 1 << endl; // n is incremented one extra time in the loop
|
||||||
|
return 0;
|
||||||
|
}
|
25
Luogu/P1036随机选数.cpp
Normal file
25
Luogu/P1036随机选数.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void matrix(int** arr, int x , int a , int b){
|
||||||
|
int pt = new int [x];
|
||||||
|
//start
|
||||||
|
int round = a * b;
|
||||||
|
for(int xxx = 0 ; xxx < round ; xxx++){
|
||||||
|
for(int i = 0; i < x ; i++){
|
||||||
|
pt[i] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
int m,n;
|
||||||
|
cin >> m >> n;
|
||||||
|
int** p = new int* [m];
|
||||||
|
for(int i = 0; i < m ;i++){
|
||||||
|
p[i] = new int [n];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
18
Luogu/P1046 [NOIP2005 普及组] 陶陶摘苹果.cpp
Normal file
18
Luogu/P1046 [NOIP2005 普及组] 陶陶摘苹果.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int a[11];
|
||||||
|
for(int i=0;i<10;i++){
|
||||||
|
cin>>a[i];
|
||||||
|
}
|
||||||
|
int index;
|
||||||
|
int sum=0;
|
||||||
|
cin>>index;
|
||||||
|
index+=30;
|
||||||
|
for(int i=0;i<10;i++){
|
||||||
|
if(a[i]<=index) sum++;
|
||||||
|
}
|
||||||
|
cout<<sum<<endl;
|
||||||
|
return 0;
|
||||||
|
}
|
6
Luogu/P1047 [NOIP 2005 普及组] 校门外的树.cpp
Normal file
6
Luogu/P1047 [NOIP 2005 普及组] 校门外的树.cpp
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main(){
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
28
Luogu/P1047校外的树.cpp
Normal file
28
Luogu/P1047校外的树.cpp
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main(){
|
||||||
|
int l,m;
|
||||||
|
int start,end;
|
||||||
|
cin>>l>>m;
|
||||||
|
int a[l+1];
|
||||||
|
for(int i=0;i<=l;i++){
|
||||||
|
a[i]=1;
|
||||||
|
}
|
||||||
|
for(int i=0;i<m;i++){
|
||||||
|
cin>>start>>end;
|
||||||
|
//cout<<"yes"<<endl;
|
||||||
|
for(int j=start;j<=end;j++){
|
||||||
|
a[j]=0;
|
||||||
|
//cout<<j<<" set 0"<<endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int js=0;
|
||||||
|
for(int i=0;i<=l;i++){
|
||||||
|
//cout<<i<<" "<<a[i]<<endl;
|
||||||
|
if(a[i]==1) {
|
||||||
|
js++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout<<js<<endl;
|
||||||
|
return 0;
|
||||||
|
}
|
51
Luogu/P1104Birthday.cpp
Normal file
51
Luogu/P1104Birthday.cpp
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <cstring>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
int birthdays[n][3];
|
||||||
|
string name[n];
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
cin>>name[i]>>birthdays[i][0]>>birthdays[i][1]>>birthdays[i][2];
|
||||||
|
}
|
||||||
|
bool flag = false;
|
||||||
|
while (flag == false){
|
||||||
|
int js = 0;
|
||||||
|
for (int i = 0; i < n - 1; i++) {
|
||||||
|
if(birthdays[i][0]>birthdays[i+1][0]){
|
||||||
|
js++;
|
||||||
|
swap(name[i],name[i+1]);
|
||||||
|
swap(birthdays[i][0],birthdays[i+1][0]);
|
||||||
|
swap(birthdays[i][1],birthdays[i+1][1]);
|
||||||
|
swap(birthdays[i][2],birthdays[i+1][2]);
|
||||||
|
}
|
||||||
|
if(birthdays[i][0]==birthdays[i+1][0]&&birthdays[i][1]>birthdays[i+1][1]){
|
||||||
|
js++;
|
||||||
|
swap(name[i],name[i+1]);
|
||||||
|
swap(birthdays[i][0],birthdays[i+1][0]);
|
||||||
|
swap(birthdays[i][1],birthdays[i+1][1]);
|
||||||
|
swap(birthdays[i][2],birthdays[i+1][2]);
|
||||||
|
}
|
||||||
|
if(birthdays[i][0]==birthdays[i+1][0]&&birthdays[i][1]==birthdays[i+1][1]&&birthdays[i][2]>birthdays[i+1][2]){
|
||||||
|
js++;
|
||||||
|
swap(name[i],name[i+1]);
|
||||||
|
swap(birthdays[i][0],birthdays[i+1][0]);
|
||||||
|
swap(birthdays[i][1],birthdays[i+1][1]);
|
||||||
|
swap(birthdays[i][2],birthdays[i+1][2]);
|
||||||
|
}
|
||||||
|
if(birthdays[i][0]==birthdays[i+1][0]&&birthdays[i][1]==birthdays[i+1][1]&&birthdays[i][2]==birthdays[i+1][2]){
|
||||||
|
swap(name[i],name[i+1]);
|
||||||
|
swap(birthdays[i][0],birthdays[i+1][0]);
|
||||||
|
swap(birthdays[i][1],birthdays[i+1][1]);
|
||||||
|
swap(birthdays[i][2],birthdays[i+1][2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(js == 0) flag = true;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
cout<<name[i]<<endl;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
36
Luogu/P1128yinshu.cpp
Normal file
36
Luogu/P1128yinshu.cpp
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <cmath>
|
||||||
|
using namespace std;
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
cin>>n;
|
||||||
|
long long m=n+1;
|
||||||
|
bool flag=false;
|
||||||
|
int js=0;
|
||||||
|
while(flag==false)
|
||||||
|
{
|
||||||
|
js=0;
|
||||||
|
for(int i=1;i<=m;i++)
|
||||||
|
{
|
||||||
|
if(m%i==0){
|
||||||
|
js++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(js==n){
|
||||||
|
flag=true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
m++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout<<m<<endl;
|
||||||
|
/*
|
||||||
|
for(int i=0;i<js;i++){
|
||||||
|
cout<<a[i]<<" ";
|
||||||
|
}
|
||||||
|
cout<<endl;
|
||||||
|
*/
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
44
Luogu/P1138.cpp
Normal file
44
Luogu/P1138.cpp
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main() {
|
||||||
|
int n, k;
|
||||||
|
cin >> n >> k;
|
||||||
|
int a[n];
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
cin >> a[i];
|
||||||
|
}
|
||||||
|
bool flag = false;
|
||||||
|
while (flag == false)
|
||||||
|
{
|
||||||
|
int js = 0;
|
||||||
|
for(int i = 0; i < n-1; i++){
|
||||||
|
if(a[i] > a[i+1]){
|
||||||
|
swap(a[i],a[i+1]);
|
||||||
|
js++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (js == 0)
|
||||||
|
{
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
for (int i = 0; i < n - 1 ; i++) {
|
||||||
|
if(a[i] == a[i+1]){
|
||||||
|
a[i] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int js = 0;
|
||||||
|
int b[n]={0};
|
||||||
|
for(int i = 0; i < n; i++){
|
||||||
|
if(a[i] != -1){
|
||||||
|
b[js] = a[i];
|
||||||
|
js++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(k<js) cout<<b[k-1]<<endl;
|
||||||
|
else cout<<"NO RESULT"<<endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
58
Luogu/P1147 连续自然数和.cpp
Normal file
58
Luogu/P1147 连续自然数和.cpp
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <cmath>
|
||||||
|
using namespace std;
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int m;
|
||||||
|
cin>>m;
|
||||||
|
bool flag;
|
||||||
|
if(m%2==0) flag=true; //ż<><C5BC><EFBFBD><EFBFBD>Ҫż<D2AA><C5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD>
|
||||||
|
else flag=false; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int a[m]={-1};
|
||||||
|
int js=0;
|
||||||
|
for(int i=1;i<=m;i++) //<2F><>Ŀ<EFBFBD><C4BF><EFBFBD>ȷֽ<C8B7><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
if(m%i==0){
|
||||||
|
a[js]=i;
|
||||||
|
js++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ɹ<EFBFBD>
|
||||||
|
for(int i=0;i<js;i++){
|
||||||
|
cout<<a[i]<<" ";
|
||||||
|
}
|
||||||
|
cout<<endl;
|
||||||
|
*/
|
||||||
|
int front=0,end=0;//<2F><>β<EFBFBD><CEB2><EFBFBD><EFBFBD>
|
||||||
|
if(flag==false)
|
||||||
|
{
|
||||||
|
for(int i=1;i<js-1;i++)
|
||||||
|
{
|
||||||
|
front=(m/a[i])-int(a[i]/2);
|
||||||
|
end=(m/a[i])+int(a[i]/2);
|
||||||
|
if(front>0 && end>0) cout<<front<<" "<<end<<endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
double odd;
|
||||||
|
int mid=0;
|
||||||
|
if(flag==true)
|
||||||
|
{
|
||||||
|
for(int i=1;i<js-1;i++)
|
||||||
|
{
|
||||||
|
odd=m/(2*a[i]);
|
||||||
|
if(a[i]%2!=0){
|
||||||
|
front=m/a[i]-int(a[i]/2);
|
||||||
|
end=m/a[i]+int(a[i]/2);
|
||||||
|
if(front>0 && end>0) cout<<front<<" "<<end<<endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
front=m/a[i]-int(a[i]/2);
|
||||||
|
end=m/a[i]+int(a[i]/2);
|
||||||
|
if(front>0 && end>0) cout<<front<<" "<<end<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
17
Luogu/P1150 Peter 的烟.cpp
Normal file
17
Luogu/P1150 Peter 的烟.cpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main(){
|
||||||
|
int n,k;
|
||||||
|
cin>>n>>k;
|
||||||
|
int tmp=n;
|
||||||
|
int js=n;
|
||||||
|
while(tmp>k){
|
||||||
|
js+=int(tmp/k);
|
||||||
|
tmp=tmp%k+tmp/k;
|
||||||
|
}
|
||||||
|
cout<<js<<endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 4%3=1 5%3=2 2+int(5/3)=3 3%3=0
|
||||||
|
6%4=2 2+6/4=3*/
|
38
Luogu/P1308 [NOIP 2011 普及组] 统计单词数.cpp
Normal file
38
Luogu/P1308 [NOIP 2011 普及组] 统计单词数.cpp
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
char a[100001];
|
||||||
|
char test[11];
|
||||||
|
scanf("%s",test);
|
||||||
|
getchar();
|
||||||
|
scanf("%[^\n]",a);
|
||||||
|
int js=0;
|
||||||
|
//printf("strlen's test:%d\n",strlen(a));
|
||||||
|
for(int i=0;i<strlen(test);i++){
|
||||||
|
test[i]=tolower(test[i]);
|
||||||
|
}
|
||||||
|
for(int i=0;i<strlen(a);i++){
|
||||||
|
a[i]=tolower(a[i]);
|
||||||
|
}
|
||||||
|
int start=0;
|
||||||
|
bool flag=false;
|
||||||
|
for(int i=0;i<=strlen(a);i++){
|
||||||
|
int j=i;
|
||||||
|
//printf("before:%d ",j);
|
||||||
|
while(a[j]==test[j-i]&&(j-i)<=strlen(test)){
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
//printf(" after:%d\n",j);
|
||||||
|
if((j-i)==strlen(test)||(j-i)==strlen(test)+1)
|
||||||
|
js++;
|
||||||
|
if(js==1&&flag==false){
|
||||||
|
start=i;
|
||||||
|
flag=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(js!=0) printf("%d %d",js,start);
|
||||||
|
else printf("-1");
|
||||||
|
return 0;
|
||||||
|
}
|
27
Luogu/P1914 小书童——凯撒密码.cpp
Normal file
27
Luogu/P1914 小书童——凯撒密码.cpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
void pwd(char ch[52]){
|
||||||
|
for(int i=0;i<strlen(ch);i++){
|
||||||
|
if(ch[i]!='z'){
|
||||||
|
ch[i]++;
|
||||||
|
}
|
||||||
|
if(ch[i]=='z')
|
||||||
|
ch[i]='a';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int main(){
|
||||||
|
int n;
|
||||||
|
scanf("%d",&n);
|
||||||
|
char a[52];
|
||||||
|
scanf("%s",a);
|
||||||
|
for(int i=0;i<strlen(a);i++){
|
||||||
|
if(a[i]+n>=123)
|
||||||
|
a[i]+=n-26;
|
||||||
|
else{
|
||||||
|
a[i]+=n;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
printf("%s",a);
|
||||||
|
return 0;
|
||||||
|
}
|
18
Luogu/P1980 [NOIP 2013 普及组] 计数问题.cpp
Normal file
18
Luogu/P1980 [NOIP 2013 普及组] 计数问题.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
//using namespace std;
|
||||||
|
int main(){
|
||||||
|
int a;
|
||||||
|
char b;
|
||||||
|
scanf("%d %c",&a,&b);
|
||||||
|
char tmp[10]="";
|
||||||
|
int js=0;
|
||||||
|
for(int i=1;i<=a;i++){
|
||||||
|
sprintf(tmp,"%d",i);
|
||||||
|
for(int j=0;j<strlen(tmp);j++){
|
||||||
|
if(tmp[j]==b) js++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("%d",js);
|
||||||
|
return 0;
|
||||||
|
}
|
11
Luogu/P5705 【深基2.例7】数字反转.cpp
Normal file
11
Luogu/P5705 【深基2.例7】数字反转.cpp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
char a[10]="";
|
||||||
|
scanf("%c%c%c%c%c",&a[0],&a[1],&a[2],&a[3],&a[4]);
|
||||||
|
for(int i=strlen(a);i>=0;i--){
|
||||||
|
printf("%c",a[i]);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
11
Luogu/P5706 【深基2.例8】再分肥宅水.cpp
Normal file
11
Luogu/P5706 【深基2.例8】再分肥宅水.cpp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
double t;
|
||||||
|
int n;
|
||||||
|
scanf("%lf %d",&t,&n);
|
||||||
|
t/=n;
|
||||||
|
n*=2;
|
||||||
|
printf("%.3f\n%d",t,n);
|
||||||
|
return 0;
|
||||||
|
}
|
26
Luogu/P5707.cpp
Normal file
26
Luogu/P5707.cpp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
double s,v;
|
||||||
|
scanf("%lf %lf",&s,&v);
|
||||||
|
double mind;
|
||||||
|
mind=s/v+10;
|
||||||
|
//printf("%.15f\n",mind);
|
||||||
|
int min;
|
||||||
|
min=ceil(mind);
|
||||||
|
int h=0;
|
||||||
|
h=min/60;
|
||||||
|
min=min%60;
|
||||||
|
if(h<=7){
|
||||||
|
h=7-h;
|
||||||
|
min=60-min;
|
||||||
|
printf("%02d:%2d",h,min);
|
||||||
|
}
|
||||||
|
if(h>=8){
|
||||||
|
h=31-h;
|
||||||
|
min=60-min;
|
||||||
|
printf("%02d:%2d",h,min);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
15
Luogu/P5714 【深基3.例7】肥胖问题 题解.cpp
Normal file
15
Luogu/P5714 【深基3.例7】肥胖问题 题解.cpp
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# include <stdio.h>
|
||||||
|
|
||||||
|
double m, h, bmi;
|
||||||
|
|
||||||
|
int main () {
|
||||||
|
scanf("%lf %lf",&m,&h);
|
||||||
|
bmi = m / (h * h);
|
||||||
|
if (bmi < 18.5)
|
||||||
|
printf("Underweight");
|
||||||
|
if (bmi >= 18.5 && bmi < 24)
|
||||||
|
printf("Normal");
|
||||||
|
if (bmi >= 24)
|
||||||
|
printf("%.6g\nOverweight\n",bmi);
|
||||||
|
return 0;
|
||||||
|
}
|
126
Luogu/P5730 【深基5.例10】显示屏.cpp
Normal file
126
Luogu/P5730 【深基5.例10】显示屏.cpp
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <windows.h>
|
||||||
|
char a[1000],b[1000],c[1000],d[1000],e[1000];
|
||||||
|
void set(){
|
||||||
|
for(int i=0;i<1000;i++){
|
||||||
|
a[i]='.';
|
||||||
|
b[i]='.';
|
||||||
|
c[i]='.';
|
||||||
|
d[i]='.';
|
||||||
|
e[i]='.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void print_num(int pos,char num){
|
||||||
|
if(num=='0'){
|
||||||
|
a[pos]='X';a[pos+1]='X';a[pos+2]='X';
|
||||||
|
b[pos]='X';b[pos+1]='.';b[pos+2]='X';
|
||||||
|
c[pos]='X';c[pos+1]='.';c[pos+2]='X';
|
||||||
|
d[pos]='X';d[pos+1]='.';d[pos+2]='X';
|
||||||
|
e[pos]='X';e[pos+1]='X';e[pos+2]='X';
|
||||||
|
}
|
||||||
|
if(num=='1'){
|
||||||
|
a[pos]='.';a[pos+1]='.';a[pos+2]='X';
|
||||||
|
b[pos]='.';b[pos+1]='.';b[pos+2]='X';
|
||||||
|
c[pos]='.';c[pos+1]='.';c[pos+2]='X';
|
||||||
|
d[pos]='.';d[pos+1]='.';d[pos+2]='X';
|
||||||
|
e[pos]='.';e[pos+1]='.';e[pos+2]='X';
|
||||||
|
}
|
||||||
|
if(num=='2'){
|
||||||
|
a[pos]='X';a[pos+1]='X';a[pos+2]='X';
|
||||||
|
b[pos]='.';b[pos+1]='.';b[pos+2]='X';
|
||||||
|
c[pos]='X';c[pos+1]='X';c[pos+2]='X';
|
||||||
|
d[pos]='X';d[pos+1]='.';d[pos+2]='.';
|
||||||
|
e[pos]='X';e[pos+1]='X';e[pos+2]='X';
|
||||||
|
}
|
||||||
|
if(num=='3'){
|
||||||
|
a[pos]='X';a[pos+1]='X';a[pos+2]='X';
|
||||||
|
b[pos]='.';b[pos+1]='.';b[pos+2]='X';
|
||||||
|
c[pos]='X';c[pos+1]='X';c[pos+2]='X';
|
||||||
|
d[pos]='.';d[pos+1]='.';d[pos+2]='X';
|
||||||
|
e[pos]='X';e[pos+1]='X';e[pos+2]='X';
|
||||||
|
}
|
||||||
|
if(num=='4'){
|
||||||
|
a[pos]='X';a[pos+1]='.';a[pos+2]='X';
|
||||||
|
b[pos]='X';b[pos+1]='.';b[pos+2]='X';
|
||||||
|
c[pos]='X';c[pos+1]='X';c[pos+2]='X';
|
||||||
|
d[pos]='.';d[pos+1]='.';d[pos+2]='X';
|
||||||
|
e[pos]='.';e[pos+1]='.';e[pos+2]='X';
|
||||||
|
}
|
||||||
|
if(num=='5'){
|
||||||
|
a[pos]='X';a[pos+1]='X';a[pos+2]='X';
|
||||||
|
b[pos]='X';b[pos+1]='.';b[pos+2]='.';
|
||||||
|
c[pos]='X';c[pos+1]='X';c[pos+2]='X';
|
||||||
|
d[pos]='.';d[pos+1]='.';d[pos+2]='X';
|
||||||
|
e[pos]='X';e[pos+1]='X';e[pos+2]='X';
|
||||||
|
}
|
||||||
|
if(num=='6'){
|
||||||
|
a[pos]='X';a[pos+1]='X';a[pos+2]='X';
|
||||||
|
b[pos]='X';b[pos+1]='.';b[pos+2]='.';
|
||||||
|
c[pos]='X';c[pos+1]='X';c[pos+2]='X';
|
||||||
|
d[pos]='X';d[pos+1]='.';d[pos+2]='X';
|
||||||
|
e[pos]='X';e[pos+1]='X';e[pos+2]='X';
|
||||||
|
}
|
||||||
|
if(num=='7'){
|
||||||
|
a[pos]='X';a[pos+1]='X';a[pos+2]='X';
|
||||||
|
b[pos]='.';b[pos+1]='.';b[pos+2]='X';
|
||||||
|
c[pos]='.';c[pos+1]='.';c[pos+2]='X';
|
||||||
|
d[pos]='.';d[pos+1]='.';d[pos+2]='X';
|
||||||
|
e[pos]='.';e[pos+1]='.';e[pos+2]='X';
|
||||||
|
}
|
||||||
|
if(num=='8'){
|
||||||
|
a[pos]='X';a[pos+1]='X';a[pos+2]='X';
|
||||||
|
b[pos]='X';b[pos+1]='.';b[pos+2]='X';
|
||||||
|
c[pos]='X';c[pos+1]='X';c[pos+2]='X';
|
||||||
|
d[pos]='X';d[pos+1]='.';d[pos+2]='X';
|
||||||
|
e[pos]='X';e[pos+1]='X';e[pos+2]='X';
|
||||||
|
}
|
||||||
|
if(num=='9'){
|
||||||
|
a[pos]='X';a[pos+1]='X';a[pos+2]='X';
|
||||||
|
b[pos]='X';b[pos+1]='.';b[pos+2]='X';
|
||||||
|
c[pos]='X';c[pos+1]='X';c[pos+2]='X';
|
||||||
|
d[pos]='.';d[pos+1]='.';d[pos+2]='X';
|
||||||
|
e[pos]='X';e[pos+1]='X';e[pos+2]='X';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void print_space(int pos){
|
||||||
|
a[pos]='.';b[pos]='.';c[pos]='.';d[pos]='.';e[pos]='.';
|
||||||
|
}
|
||||||
|
int main(){
|
||||||
|
set();
|
||||||
|
int n;
|
||||||
|
scanf("%d",&n);
|
||||||
|
char k[n];
|
||||||
|
scanf("%s",&k);
|
||||||
|
int tmp=n*3+n-1;
|
||||||
|
int js=0;
|
||||||
|
for(int i=0;i<n;i++){
|
||||||
|
print_num(js,k[i]);
|
||||||
|
js+=3;
|
||||||
|
if(js<=tmp-3){
|
||||||
|
print_space(js);
|
||||||
|
js++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i=0;i<tmp;i++){
|
||||||
|
printf("%c",a[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
for(int i=0;i<tmp;i++){
|
||||||
|
printf("%c",b[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
for(int i=0;i<tmp;i++){
|
||||||
|
printf("%c",c[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
for(int i=0;i<tmp;i++){
|
||||||
|
printf("%c",d[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
for(int i=0;i<tmp;i++){
|
||||||
|
printf("%c",e[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
system("pause");
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in New Issue
Block a user