Update: Rename folder name to XSMOJ

This commit is contained in:
2025-02-14 02:44:20 +00:00
parent 394e431a4a
commit c8863a5850
243 changed files with 11 additions and 39 deletions

View File

@ -0,0 +1,18 @@
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
int sum1=0,sum2=0;
int a,n;
cin >>n>>a;
for(int i=0;i<n;i++){
sum1=sum1*10+a;
sum2+=sum1;
}
cout <<sum2;
return 0;
}

View File

@ -0,0 +1,25 @@
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
int a,b,c=0,d[10000],i=0;
cin >>a;
b=a;
while(a){
a/=10;
c++;
}
while(b){
d[i]=b%10;
b/=10;
i++;
}
for(int i=0;i<c;i++){
cout <<d[i]<<" ";
}
return 0;
}

25
XSMOJ/#146. 回文数.cpp Normal file
View File

@ -0,0 +1,25 @@
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
int a;
int b;
int sum=0;
cin >>a;
b=a;
while(a){
sum=sum*10+a%10;
a/=10;
}
if(b==sum){
cout <<"yes";
}
else{
cout <<"no";
}
return 0;
}

View File

@ -0,0 +1,29 @@
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
int a[10000],b,c,d,e,f,g=0;
cin >>b;
for(int i=0;i<b;i++){
cin >>a[i];
}
for(int i=0;i<b;i++){
c=a[i]%10;
a[i]/=10;
d=a[i]%10;
a[i]/=10;
e=a[i]%10;
a[i]/=10;
f=a[i]%10;
a[i]/=10;
if((c-d-e-f)>0){
g++;
}
}
cout <<g;
return 0;
}

View File

@ -0,0 +1,34 @@
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
int a[100][100],b[100][100],c,d;
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
cin >>a[i][j];
}
}
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
b[i][j]=a[i][j];
}
}
cin >>c>>d;
for(int i=0;i<5;i++){
a[c-1][i]=a[d-1][i];
}
for(int i=0;i<5;i++){
a[d-1][i]=b[c-1][i];
}
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
cout <<a[i][j]<<" ";
}
cout <<endl;
}
return 0;
}

View File

@ -0,0 +1,19 @@
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
char a[10000];
int b=0;
gets(a);
for(int i=0;i<strlen(a);i++){
if(a[i]>='0' && a[i]<='9'){
b++;
}
}
cout <<b;
return 0;
}

View File

@ -0,0 +1,17 @@
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
char a[10000];
char b;
cin >>a>>b;
cout <<a[0];
for(int i=1;i<strlen(a);i++){
cout <<b<<a[i];
}
return 0;
}

View File

@ -0,0 +1,21 @@
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
char a[10000],c;
int b;
cin >>a>>b>>c;
for(int i=0;i<strlen(a);i++){
if(i==(b-1)){
cout <<c;
}
else{
cout <<a[i];
}
}
return 0;
}

View File

@ -0,0 +1,23 @@
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
char a[10000];
int b=0;
cin >>a;
for(int i=0;i<strlen(a);i++){
if(a[i]==','){
cout <<b<<" ";
b=0;
}
else{
b++;
}
}
cout <<b;
return 0;
}

View File

@ -0,0 +1,27 @@
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
char a[10000];
cin >>a;
int b;
int flag=1;
for(int i=strlen(a)-1;i>=0;i--){
b=strlen(a)-i-1;
if(a[i]!=a[b]){
flag=0;
break;
}
}
if(flag==1){
cout <<"Yes";
}
else{
cout <<"No";
}
return 0;
}

BIN
XSMOJ/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,18 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
using namespace std;
int main(){
int a;
cin >>a;
for(int i=1;i<=a;i++){
for(int j=1;j<=a;j++){
if(i!=j){
cout <<i<<" "<<j<<endl;
}
}
}
return 0;
}

View File

@ -0,0 +1,16 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
using namespace std;
int main(){
int a;
cin >>a;
for(int i=1;i<=a;i++){
for(int j=i+1;j<=a;j++){
cout <<i<<" "<<j<<endl;
}
}
return 0;
}

25
XSMOJ/3n+1问题.cpp Normal file
View File

@ -0,0 +1,25 @@
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
int a;
int b=0;
cin >>a;
while(a>1){
if(a%2==1){
a=a*3+1;
b++;
}
if(a%2==0){
a=a/2;
b++;
}
}
cout <<b;
return 0;
}

View File

@ -0,0 +1,31 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
struct wjh{
string name;
d tw;
l ks;
}arr[10000];
int main(){
l cnt=0;
l a;
cin >>a;
for(int i=0;i<a;i++){
cin >>arr[i].name>>arr[i].tw>>arr[i].ks;
}
for(int i=0;i<a;i++){
if(arr[i].tw>=37.5 && arr[i].ks==1){
cout <<arr[i].name<<endl;
cnt++;
}
}
cout <<cnt;
return 0;
}

View File

@ -0,0 +1,26 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
using namespace std;
int main(){
int a,b,c,d=0;
cin >>a>>b>>c;
if(a>=60){
d++;
}
if(b>=60){
d++;
}
if(c>=60){
d++;
}
if(d==2){
cout <<1;
}
else{
cout <<0;
}
return 0;
}

6
XSMOJ/Hello World.cpp Normal file
View File

@ -0,0 +1,6 @@
#include <iostream>
using namespace std;
int main(){
cout <<"Hello World";
return 0;
}

29
XSMOJ/TeX中的引号.cpp Normal file
View File

@ -0,0 +1,29 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
int main(){
c a[1000];
l cnt=0;
cin.getline(a,1000);
for(int i=0;i<strlen(a);i++){
if(a[i]=='"' && cnt%2==0){
cout <<"``";
cnt++;
}
else if(a[i]=='"' && cnt%2==1){
cout <<"''";
cnt++;
}
else{
cout <<a[i];
}
}
return 0;
}

View File

@ -0,0 +1,30 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
void s(char a,char b,char c,int n){
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a<EFBFBD><61>ʾ<EFBFBD><CABE>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>b<EFBFBD><62>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>c<EFBFBD><63>ʾĿ<CABE><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>n<EFBFBD><6E>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
if(n==1){
printf("%c->%c\n",a,c);//<2F>ݹ鵽1<E9B5BD><31><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>ֱ<EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
return;
}
s(a,c,b,n-1);//<2F>Ƚ<EFBFBD>n-1<><31> <20><>A<EFBFBD><41>B
printf("%c->%c\n",a,c);
s(b,a,c,n-1);//<2F>ٽ<EFBFBD>n-1<><31> <20><>B<EFBFBD><42>C
}
int main(){
char a,b,c;
int d;
cin >>d>>a>>b>>c;
s(a,b,c,d);
return 0;
}

View File

@ -0,0 +1,14 @@
#include <iostream>
using namespace std;
int main(){
int a;
int sum;
cin >>a;
for(sum=1;a>0;a--){
sum*=a;
}
cout <<sum;
return 0;
}

View File

@ -0,0 +1,55 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
string b;
queue<int> que;
int main(){
freopen("A.in","r",stdin);
freopen("A.out","w",stdout);
int a;
cin >>a;
for(int i=0;i<a;i++){
cin >>b;
if(b=="push"){
int x;
cin >>x;
que.push(x);
}
else if(b=="front" && que.empty()==0){
cout <<que.front()<<endl;
}
else if(b=="front" && que.empty()==1){
cout <<"error"<<endl;
}
else if(b=="pop" && que.empty()==0){
que.pop();
}
else if(b=="pop" && que.empty()==1){
cout <<"error"<<endl;
}
else if(b=="empty"){
if(que.empty()==1){
cout <<"empty"<<endl;
}
if(que.empty()==0){
cout <<"not empty"<<endl;
}
}
else if(b=="clear"){
while(que.empty()!=true){
que.pop();
}
}
}
return 0;
}

View File

@ -0,0 +1,18 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
double a,sum=0;
int b=0;
scanf("%lf",&a);
while(sum<=a){
b++;
sum+=1*1.0/b;
}
printf("%d",b);
return 0;
}

View File

@ -0,0 +1,22 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
int a,b,sum=0;
scanf("%d%d",&a,&b);
for(int i=a;i<=b;i++){
int c=i;
while(c){
if(c%10==2){
sum++;
}
c/=10;
}
}
printf("%d",sum);
return 0;
}

View File

@ -0,0 +1,27 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
int n,x,y;
int a[10005];
int b[10005];
int g[10005];
int k[10005];
using namespace std;
int main(){
cin >>n;
for(int i=0;i<n;i++){
cin >>a[i]>>b[i]>>g[i]>>k[i];
}
cin >>x>>y;
for(int i=n-1;i>=0;i--){
if(x>=a[i] && x<=a[i]+g[i] && y>=b[i] && y<=b[i]+k[i]){
cout <<i+1;
return 0;
}
}
cout <<"-1";
return 0;
}

View File

@ -0,0 +1,17 @@
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int a,b=1,sum=0;
cin >>a;
while(a>b){
sum+=b*b;
a-=b;
b++;
}
sum+=b*a;
cout <<sum;
return 0;
}

View File

@ -0,0 +1,26 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
int a,b;
cin >>a>>b;
long long flag=0;
for(int i=0;i<=a;i++){
for(int j=0;j<=a;j++){
if(i*2+j*4==b && i+j==a){
cout <<i<<" "<<j;
}
else{
flag++;
}
}
}
if(flag==(a+1)*(a+1)){
cout <<"No answer";
}
return 0;
}

View File

@ -0,0 +1,26 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
using namespace std;
int main(){
int a,b,c[100000];
cin >>a>>b;
for(int i=1;i<=a;i++){
c[i]=0;
}
for(int i=2;i<=b;i++){
for(int j=1;j<=a;j++){
if(j%i==0){
c[j]++;
}
}
}
for(int i=1;i<=a;i++){
if(c[i]%2==0){
cout <<i<<" ";
}
}
return 0;
}

View File

@ -0,0 +1,16 @@
#include <iostream>
using namespace std;
signed main()
{
int n;
cin >> n ;
for(int i = 1; i <= n; ++ i)
{
string s1, s2;
cin >> s1 >> s2 ;
if(s1 == "Rock" && s2 == "Scissors" || s1 == "Scissors" && s2 == "Paper" || s1 == "Paper" && s2 == "Rock") cout << "Player1" << endl ;
else if(s1 == s2) cout << "Tie" << endl ;
else cout << "Player2" << endl ;
}
}

View File

@ -0,0 +1,24 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
typedef char c;
int arr[10000000];
using namespace std;
int main(){
int a;
cin >>a;
for(int i=0;i<a;i++){
cin >>arr[i];
}
sort(arr,arr+a);
for(int i=0;i<a;i++){
cout <<arr[i]<<" ";
}
return 0;
}

View File

@ -0,0 +1,27 @@
#include <iostream>
#define int long long
using namespace std;
signed main()
{
int N;
cin >> N;
int count = 0;
for (int i = 1; i <= N / 3; ++i)
{
for (int j = i + 1; j <= N / 2; ++j)
{
int k = N - i - j;
if (k > j && k != 3 && k != 7 && i != 3 && i != 7 && j != 3 && j != 7 && k != 0)
{
++count;
}
}
}
cout << count << endl;
return 0;
}

View File

@ -0,0 +1,35 @@
#include <iostream>
#include <vector>
using namespace std;
struct Rectangle {
int x1, y1, x2, y2;
};
int main() {
int n;
cin >> n;
vector<Rectangle> rectangles(n);
for (int i = 0; i < n; ++i) {
cin >> rectangles[i].x1 >> rectangles[i].y1 >> rectangles[i].x2 >> rectangles[i].y2;
}
int totalArea = 0;
for (int i = 0; i < n; ++i) {
totalArea += (rectangles[i].x2 - rectangles[i].x1) * (rectangles[i].y2 - rectangles[i].y1);
for (int j = i + 1; j < n; ++j) {
int x_overlap = max(0, min(rectangles[i].x2, rectangles[j].x2) - max(rectangles[i].x1, rectangles[j].x1));
int y_overlap = max(0, min(rectangles[i].y2, rectangles[j].y2) - max(rectangles[i].y1, rectangles[j].y1));
totalArea -= x_overlap * y_overlap;
}
}
cout << totalArea << endl;
return 0;
}

View File

@ -0,0 +1,26 @@
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int a,b,c,n;
cin >>a>>b>>c;
if(a>b){
n=a;
a=b;
b=n;
}
if(b>c){
n=b;
b=c;
c=n;
}
if(a>b){
n=a;
a=b;
b=n;
}
cout <<a<<" "<<b<<" "<<c;
return 0;
}

37
XSMOJ/三整数排序.cpp Normal file
View File

@ -0,0 +1,37 @@
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int a,b,c;
cin >>a>>b>>c;
if(a<=b && a<=c){
cout <<a<<" ";
}
else if(b<=a && b<=c){
cout <<b<<" ";
}
else if(c<=a && c<=b){
cout <<c<<" ";
}
if((a>=c && a<=b) || (a<=c && a>=b)){
cout <<a<<" ";
}
else if((b>=c && b<=a) || (b<=c && b>=a)){
cout <<b<<" ";
}
else if((c>=a && a<=b) || (c<=a && c>=b)){
cout <<c<<" ";
}
if(a>=b && a>=c){
cout <<a;
}
else if(b>=a && b>=c){
cout <<b;
}
else if(c>=b && c>=a){
cout <<c;
}
return 0;
}

27
XSMOJ/三角形判断.cpp Normal file
View File

@ -0,0 +1,27 @@
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int a;
int b;
int c;
cin >>a>>b>>c;
if(a<b+c && b<a+c && c<b+a){
if(a==b && a==c && b==c){
cout <<"<EFBFBD>ȱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else if(a==b || a==c || b==c){
cout <<"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else if(pow(a,2)+pow(b,2)==pow(c,2)){
cout <<"ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else{
cout <<"һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
}
else{
cout <<"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
return 0;
}

View File

@ -0,0 +1,15 @@
#include <iostream>
using namespace std;
int main(){
int a;
int b;
int c;
cin >>a>>b>>c;
if(a<b+c && b<a+c && c<b+a){
cout <<"yes";
}
else{
cout <<"no";
}
return 0;
}

View File

@ -0,0 +1,19 @@
#include <iostream>
using namespace std;
int main(){
int n,m,b=0;
int a[10000];
cin >>n;
for(int i=0;i<n;i++){
cin >>a[i];
}
cin >>m;
for(int i=0;i<n;i++){
if(a[i]==m){
b++;
}
}
cout <<b;
return 0;
}

View File

@ -0,0 +1,35 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
struct wjh{
string name;
int score;
}arr[10000];
int main(){
int a;
int flag=0;
cin >>a;
for(int i=0;i<a;i++){
cin >>arr[i].name>>arr[i].score;
}
for(int i=0;i<a;i++){
if(arr[i].score>=60){
}
else{
cout <<arr[i].name<<endl;
flag=1;
}
}
if(flag==0){
cout <<"Good!";
}
return 0;
}

View File

@ -0,0 +1,18 @@
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int a,b[1000],c,sum=0;
cin >>a;
for(int i=0;i<a;i++){
cin >>b[i];
}
cin >>c;
for(int i=0;i<a;i++){
if(b[i]==c){
sum++;
}
}
cout <<sum;
return 0;
}

26
XSMOJ/世界末日.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
void wjh(int x,int n){
if(n<x-1){
return;
}
cout <<n<<" ";
wjh(x,n-1);
}
int main(){
int a;
cin >>a;
wjh(1,a);
return 0;
}

View File

@ -0,0 +1,8 @@
#include <bits/stdc++.h>
using namespace std;
int main(){
int a;
cin >> a;
cout <<a%10<<a/10;
return 0;
}

26
XSMOJ/买书.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
using namespace std;
int main(){
int a,b[10000],c,d[10000];
cin >>a;
int sum=0;
for(int i=0;i<a;i++){
cin >>b[i];
}
cin >>c;
for(int i=0;i<c;i++){
cin >>d[i];
}
for(int i=0;i<c;i++){
for(int j=0;j<d[i];j++){
sum+=b[j];
}
cout <<sum<<" ";
sum=0;
}
return 0;
}

13
XSMOJ/买木板.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
int a,b;
scanf("%d%d",&a,&b);
printf("һ<EFBFBD><EFBFBD>%dԪ<64><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%dԪ",a*20,b-a*20);
return 0;
}

View File

@ -0,0 +1,18 @@
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
char a;
int b;
cin >>a;
cin >>b;
for(int i=b;i>=1;i--){
for(int j=1;j<=b;j++){
cout <<a<<" ";
}
cout <<endl;
}
return 0;
}

View File

@ -0,0 +1,13 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
int a,b;
cin >>a>>b;
return 0;
}
//https://search.bilibili.com/all?vt=25685816&keyword=minecraft%E7%BD%91%E9%A1%B5%E7%89%88%E6%95%99%E7%A8%8B

16
XSMOJ/优美数.cpp Normal file
View File

@ -0,0 +1,16 @@
#include <bits/stdc++.h>
using namespace std;
int main(){
int a;
cin >>a;
if(a>50){
cout <<"yes";
}
else if(a%2==0){
cout <<"yes";
}
else{
cout <<"no";
}
return 0;
}

20
XSMOJ/位运算符.cpp Normal file
View File

@ -0,0 +1,20 @@
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
int a,b,c,d,e,f,g,h;
cin >>a>>b;
c=a&b;
d=a|b;
e=a^b;
f=~a;
cout <<"a&b="<<c<<endl;
cout <<"a|b="<<d<<endl;
cout <<"a^b="<<e<<endl;
cout <<"~a="<<f<<endl;
cout <<"a<<b="<<(a<<b)<<endl;
cout <<"a>>b="<<(a>>b)<<endl;
return 0;
}

View File

@ -0,0 +1,34 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
int main(){
c a[1000],b[1000];
l a1[1000],b1[1000],sum1=1,sum2=1;
cin >>a>>b;
for(int i=0;i<strlen(a);i++){
a1[i]=a[i]-64;
}
for(int i=0;i<strlen(b);i++){
b1[i]=b[i]-64;
}
for(int i=0;i<strlen(a);i++){
sum1*=a1[i];
}
for(int i=0;i<strlen(b);i++){
sum2*=b1[i];
}
if(sum1%47==sum2%47){
cout <<"GO";
}
else{
cout <<"STAY";
}
return 0;
}

22
XSMOJ/分段函数.cpp Normal file
View File

@ -0,0 +1,22 @@
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
double a;
cin >>a;
if(0<=a && a<5){
cout <<fixed<<setprecision(3)<<(0-a)+2.5;
}
if(5<=a && a<10){
cout <<fixed<<setprecision(3)<<2-1.5*(a-3.0)*(a-3.0);
}
if(10<=a && a<20){
cout <<fixed<<setprecision(3)<<a/2.0-1.5;
}
return 0;
}

View File

@ -0,0 +1,16 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
long long a;
scanf("%lld",&a);
while(a){
printf("%lld ",a%10);
a/=10;
}
return 0;
}

View File

@ -0,0 +1,13 @@
#include <bits/stdc++.h>
using namespace std;
int main(){
int a;
cin >> a;
if(a%2==0){
cout <<"even";
}
else{
cout <<"odd";
}
return 0;
}

View File

@ -0,0 +1,16 @@
#include <bits/stdc++.h>
using namespace std;
int main(){
int a;
cin >>a;
if(a<0){
cout <<"negative";
}
if(a==0){
cout <<"zero";
}
if(a>0){
cout <<"positive";
}
return 0;
}

20
XSMOJ/判断数正负.cpp Normal file
View File

@ -0,0 +1,20 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
using namespace std;
int main(){
int a;
cin >>a;
if(a>0){
cout <<"positive";
}
if(a==0){
cout <<"zero";
}
if(a<0){
cout <<"negative";
}
return 0;
}

View File

@ -0,0 +1,18 @@
#include <iostream>
using namespace std;
int main(){
int a,b=0;
cin >>a;
if(a==0){
cout <<"1";
return 0;
}
while(a){
a/=10;
b++;
}
cout <<b;
return 0;
}

14
XSMOJ/判断素数.cpp Normal file
View File

@ -0,0 +1,14 @@
#include <iostream>
using namespace std;
int main(){
int a,b=0;
cin >>a;
for(int i=2;i*i<=a;i++){
if(a%i==0){
cout <<a<<" is a prime number.";
return 0;
}
}
cout <<a<<" is not a prime number.";
return 0;
}

13
XSMOJ/判断闰年.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <bits/stdc++.h>
using namespace std;
int main(){
int a;
cin >>a;
if(a%4==0 && a%100>0 || a%400==0 && a%3200>0){
cout <<"Y";
}
else{
cout <<"N";
}
return 0;
}

View File

@ -0,0 +1,26 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
void wjh(int a){
if(a<=0){
return;
}
wjh(a/2);
cout <<a%2;
}
int main(){
int a;
cin >>a;
wjh(a);
return 0;
}

9
XSMOJ/叠罗汉.cpp Normal file
View File

@ -0,0 +1,9 @@
#include <iostream>
using namespace std;
int main(){
cout <<" # "<<endl;
cout <<" # # "<<endl;
cout <<" # # # "<<endl;
cout <<"# # # #"<<endl;
return 0;
}

View File

@ -0,0 +1,11 @@
#include <bits/stdc++.h>
using namespace std;
int main(){
char a;
cin >>a;
cout <<" "<<a<<" "<<endl;
cout <<" "<<a<<" "<<a<<" "<<endl;
cout <<" "<<a<<" "<<a<<" "<<a<<" "<<endl;
cout <<a<<" "<<a<<" "<<a<<" "<<a;
return 0;
}

25
XSMOJ/含K个3的数.cpp Normal file
View File

@ -0,0 +1,25 @@
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
int a,b,c=0,d;
cin >>a>>b;
d=a;
while(a){
if(a%10==3){
c++;
}
a/=10;
}
if(d%19==0 && c==b){
cout <<"YES";
}
else{
cout <<"NO";
}
return 0;
}

View File

@ -0,0 +1,26 @@
#include <iostream>
using namespace std;
int main(){
int a,flag1=1,flag2=1;
cin >>a;
for(int i=2;i<=a-2;i++){
for(int j=2;j<i;j++){
if(i%j==0){
flag1=0;
break;
}
}
for(int k=2;k<a-i;k++){
if((a-i)%k==0){
flag2=0;
break;
}
}
if(flag1==1 && flag2==1){
cout <<a<<"="<<i<<"+"<<a-i;
break;
}
}
return 0;
}

View File

@ -0,0 +1,35 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
using namespace std;
int main(){
l a,b,c[100][100],e[100][100];
cin >>a>>b;
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
cin >>c[i][j];
}
}
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
e[i][j]=c[i][j];
}
}
for(int i=1;i<a-1;i++){
for(int j=1;j<b-1;j++){
c[i][j]=round((e[i+1][j]+e[i-1][j]+e[i][j-1]+e[i][j+1]+e[i][j])*1.0/5);
}
}
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
cout <<c[i][j]<<" ";
}
cout <<endl;
}
return 0;
}

View File

@ -0,0 +1,16 @@
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
const double pi = acos(-1.0);
double r;
double h;
cin >>r>>h;
cout <<"Area = "<<fixed<<setprecision(3)<<2*pi*r*h+2*pi*pow(r,2);
return 0;
}

16
XSMOJ/奇数求和.cpp Normal file
View File

@ -0,0 +1,16 @@
#include <bits/stdc++.h>
using namespace std;
int main(){
int a;
int b;
int c=0;
cin >>a>>b;
while(a<=b){
if(a%2==1){
c+=a;
}
a++;
}
cout <<c;
return 0;
}

View File

@ -0,0 +1,16 @@
#include <iostream>
using namespace std;
int main(){
int a;
int b;
int c;
int d;
cin >>a>>b>>c>>d;
if((a>=10 && b>=10 && c>=25 && d>=25) || (a>=10 && b>=10 && c>=25 && d>=25 ) || (a>=25 && b>=25 && c>=10 && d>=10) || (a>=10 && b>=25 && c>=10 && d>=25)|| (a>=10 && b>=25 && c>=25 && d>=10) || (a>=25 && b>=10 && c>=10 && d>=25) || (a>=25 && b>=10 && c>=25 && d>=10)){
cout <<"<EFBFBD>ó<EFBFBD>";
}
else{
cout <<"<EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD>";
}
return 0;
}

View File

@ -0,0 +1,17 @@
#include <iostream>
#include <cstring>
using namespace std;
int main(){
char a[10000];
cin >>a;
for(int i=0;i<strlen(a);i++){
if(a[i]>='0' && a[i]<='9'){
}
else{
cout <<a[i];
}
}
return 0;
}

24
XSMOJ/字符倒三角.cpp Normal file
View File

@ -0,0 +1,24 @@
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int a;
char b='a';
cin >>a;
for(int i=a;i>=1;i--){
for(int j=(a-i)*2;j>=1;j--){
cout <<" ";
}
for(int j=i;j>=1;j--){
cout <<b<<" ";
b++;
if(b>'z'){
b-=26;
}
}
cout <<endl;
}
return 0;
}

22
XSMOJ/密码破解.cpp Normal file
View File

@ -0,0 +1,22 @@
#include <iostream>
#include <cstring>
using namespace std;
int main(){
char a[10000];
int b=0,sum=0;
cin >>a;
for(int i=0;i<strlen(a);i++){
if(a[i]>='0' && a[i]<='9'){
b=b*10+(a[i]-48);
}
else{
sum+=b;
b=0;
}
}
sum+=b;
cout <<sum;
return 0;
}

27
XSMOJ/密码翻译.cpp Normal file
View File

@ -0,0 +1,27 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
int main(){
c a[100000];
cin.getline(a,100000);
for(int i=0;i<strlen(a);i++){
if((a[i]>='a' && a[i]<='y') || (a[i]>='A' && a[i]<='Y')){
a[i]+=1;
}
else if(a[i]=='z'){
a[i]='a';
}
else if(a[i]=='Z'){
a[i]='A';
}
}
cout <<a;
return 0;
}

View File

@ -0,0 +1,17 @@
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
int main(){
long long money=1;
long long sum=1;
int day=1;
for(day=1;day<=1234567890;day+=1){
cout <<"<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>"<<day<<"<EFBFBD><EFBFBD>"<<endl;
cout <<"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǯ<EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD>"<<money<<endl;
cout <<"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۼƸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǯ<EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD>"<<sum<<endl;
money=money*2;
sum=sum+money;
}
return 0;
}

13
XSMOJ/对齐输出.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
printf("%8d %8d %8d\n",a,b,c);
return 0;
}

View File

@ -0,0 +1,25 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
int wjh(int a){
if(a<=2){
return 1;
}
return wjh(a-1)+wjh(a-2);
}
int main(){
int a;
cin >>a;
cout <<wjh(a)*2;
return 0;
}

View File

@ -0,0 +1,13 @@
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
double a;
double b;
long long c;
cin >>a>>b>>c;
cout <<c<<endl;
cout <<fixed<<setprecision(2)<<b<<endl;
cout <<fixed<<setprecision(9)<<a;
return 0;
}

13
XSMOJ/小玉在游泳.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <iostream>
using namespace std;
int main(){
double a,b=2.0,sum=0,c=0;
scanf("%lf",&a);
while(sum<a){
sum+=b;
b*=0.98;
c++;
}
printf("%.0lf",c);
return 0;
}

View File

@ -0,0 +1,19 @@
#include <bits/stdc++.h>
using namespace std;
int main(){
int a;
cin >>a;
if(a<=150){
cout <<fixed<<setprecision(1)<<a*0.4463;
return 0;
}
if(a>150 && a<=400){
cout <<fixed<<setprecision(1)<<150*0.4463+(a-150)*0.4663;
return 0;
}
if(a>400){
cout <<fixed<<setprecision(1)<<150*0.4463+(400-150)*0.4663+(a-400)*0.5663;
return 0;
}
return 0;
}

19
XSMOJ/小码君分班.cpp Normal file
View File

@ -0,0 +1,19 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
int a,b;
cin >>a>>b;
if(b%a==0){
cout <<"ÿ<EFBFBD><EFBFBD>"<<b/a<<"<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<<endl;
}
else{
cout <<"ÿ<EFBFBD><EFBFBD>"<<b/a<<"<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<<endl;
cout <<"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<<b-b/a*a<<"<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>û<EFBFBD>ְࡣ";
}
return 0;
}

View File

@ -0,0 +1,39 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
struct wjh{
string name;
int n;
int m;
int id;
}arr[100000];
bool cmp(wjh a,wjh b){
if(a.m==b.m){
if(a.n==b.n){
return a.id<b.id;
}
return a.n<b.n;
}
return a.m<b.m;
}
int main(){
int a;
cin >>a;
for(int i=0;i<a;i++){
cin >>arr[i].name>>arr[i].n>>arr[i].m;
arr[i].id=i;
}
sort(arr,arr+a,cmp);
for(int i=0;i<a;i++){
cout <<arr[i].name<<" "<<arr[i].n<<" "<<arr[i].m<<endl;
}
return 0;
}

25
XSMOJ/小码君刷题.cpp Normal file
View File

@ -0,0 +1,25 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
int a,b,c,d,e,sum=0;
cin >>a>>b>>c>>d>>e;
for(int i=0;i<a;i++){
if(i>=1 && i%c==0){
b+=d;
}
sum+=b;
}
cout <<sum<<endl;
if(sum>=e){
cout <<"Yes";
}
else{
cout <<"No";
}
return 0;
}

View File

@ -0,0 +1,25 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
using namespace std;
int main(){
l a,b,c[100][100];
cin >>a>>b;
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
cin >>c[i][j];
}
}
for(int i=b-1;i>=0;i--){
for(int j=0;j<a;j++){
cout <<c[j][i]<<" ";
}
cout <<endl;
}
return 0;
}

View File

@ -0,0 +1,33 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
int n,m;
int arr[1000][1000];
int cnt=0;
int main(){
cin.tie(NULL);
cout.tie(NULL);
cin >>n>>m;
for(int i=1;i<=n;i++){
int x;
cin>>x;
arr[i][x]=1;
}
for(int i=n;i>=1;i--){
for(int j=1;j<=i;j++){
arr[i][j]+=max(max(arr[i+1][j+1],arr[i+1][j-1]),arr[i+1][j]);
}
}
cout <<arr[1][1];
return 0;
}

View File

@ -0,0 +1,29 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
int a,b[100],c[100],d[100],flag[100];
cin >>a;
for(int i=0;i<5;i++){
cin >>b[i];
}
for(int i=0;i<a;i++){
cin >>c[i];
}
for(int i=0;i<a;i++){
cin >>d[i];
}
for(int i=0;i<a;i++){
if(d[i]==1){
b[i]=floor(b[i]*1.0/2);
}
}
for(int i=0;i<a;i++){
}
return 0;
}

View File

@ -0,0 +1,38 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
long long a,b,c[100000],d[100000],e[100000],flag=0;
using namespace std;
int main(){
cin >>a>>b;
for(int i=1;i<=a;i++){
cin >>c[i];
}
for(int i=1;i<=b;i++){
cin >>d[i];
}
for(int i=1;i<=b;i++){
if(c[d[i]-1]>=40){
e[d[i]-1]=1;
}
if(c[d[i]]>=40){
e[d[i]]=1;
}
if(c[d[i]+1]>=40){
e[d[i]+1]=1;
}
}
for(int i=1;i<=a;i++){
if(e[i]==1){
cout <<i<<" ";
flag=1;
}
}
if(flag==0){
cout <<0;
}
return 0;
}

34
XSMOJ/小码君查房.cpp Normal file
View File

@ -0,0 +1,34 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
int a,b,c[10000],d[10000],flag1=0,flag2=0;
cin >>a>>b;
for(int i=1;i<=a;i++){
cin >>c[i];
}
for(int i=1;i<=b;i++){
cin >>d[i];
}
for(int i=1;i<a;i++){
if(c[i]>=40 && i==d[i]){
flag1=1;
flag2=1;
cout <<i<<" ";
}
if(c[i]>=40 && i!=d[i]){
flag2=1;
}
}
if(flag1==0 && flag2!=0){
cout <<"luck";
}
if(flag2==0){
cout <<"quiet";
}
return 0;
}

View File

@ -0,0 +1,26 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
char a[10000];
int sum=0;
gets(a);
for(int i=0;i<strlen(a);i++){
if(a[i]=='A' && a[i+1]=='A' && a[i+2]=='C'){
sum+=2;
}
else if(a[i]=='A' && a[i+1]=='C' && a[i+2]=='C'){
sum+=2;
}
else if(a[i]=='A' && a[i+1]=='C' && (a[i]!='C' && a[i]!='A')){
sum++;
}
}
cout <<sum;
return 0;
}

View File

@ -0,0 +1,28 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
int main(){
c a[1000];
l cnt=0;
cin >>a;
l tem=0;
for(int i=0;i<strlen(a);i++){
if(a[i]=='D'){
tem=1;
}
if(a[i]==','){
cnt+=tem;
tem=0;
}
}
cnt+=tem;
cout <<cnt;
return 0;
}

View File

@ -0,0 +1,32 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
int f91(int a){
if(a<=100){
return f91(f91(a+11));
}
if(a>=101){
return a-10;
}
}
int main(){
int a;
while(1){
cin >>a;
if(a==0){
break;
}
cout <<"f91("<<a<<") = "<<f91(a)<<endl;
}
return 0;
}

View File

@ -0,0 +1,35 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
int main(){
c a[1000];
l b[1000],c=1,sum=0;
cin >>a;
for(int i=0;i<strlen(a);i++){
if(i==1 || i==5 || i==11){
continue;
}
b[i]=a[i]-48;
}
for(int i=0;i<strlen(a);i++){
if(i==1 || i==5 || i==11){
continue;
}
sum+=c*b[i];
c++;
}
if(sum%11==10){
cout <<"X";
}
else{
cout <<sum%11;
}
return 0;
}

View File

@ -0,0 +1,63 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
struct node{
int x;
int y;
};
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int sx,sy;
int ex,ey;
int n,m;
bool vis[600][600];
char mp[600][600];
void bfs(){
queue<node> que;
que.push({sx,sy});
while(!que.empty()){
node first=que.front();
que.pop();
if(first.x==ex && first.y==ey){
cout <<"Yes";
return;
}
for(int i=0;i<4;i++){
int tox=first.x+dx[i];
int toy=first.y+dy[i];
if(tox>=1 && tox<=n && toy>=1 && toy<=m && mp[tox][toy]!='#' && vis[tox][toy]==0){
que.push({tox,toy});
vis[tox][toy]=1;
}
}
}
cout <<"No";
}
int main(){
cin >>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin >>mp[i][j];
if(mp[i][j]=='s'){
sx=i;
sy=j;
}
if(mp[i][j]=='g'){
ex=i;
ey=j;
}
}
}
bfs();
return 0;
}

View File

@ -0,0 +1,64 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
struct node{
int x;
int y;
int dp;
};
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int sx,sy;
int ex,ey;
int n,m;
bool vis[600][600];
char mp[600][600];
void bfs(){
queue<node> que;
que.push({sx,sy,1});
while(!que.empty()){
node first=que.front();
que.pop();
if(first.x==ex && first.y==ey){
cout <<first.dp;
return;
}
for(int i=0;i<4;i++){
int tox=first.x+dx[i];
int toy=first.y+dy[i];
if(tox>=1 && tox<=n && toy>=1 && toy<=m && mp[tox][toy]!='X' && vis[tox][toy]==0){
que.push({tox,toy,first.dp+1});
vis[tox][toy]=1;
}
}
}
cout <<"-1";
}
int main(){
cin >>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin >>mp[i][j];
if(mp[i][j]=='S'){
sx=i;
sy=j;
}
if(mp[i][j]=='T'){
ex=i;
ey=j;
}
}
}
bfs();
return 0;
}

View File

@ -0,0 +1,57 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
struct node{
int x;
int y;
int dp;
};
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int sx,sy;
int ex,ey;
int n;
bool vis[1000][1000];
char mp[1000][1000];
void bfs(){
queue<node> que;
que.push({sx,sy,0});
while(!que.empty()){
node first=que.front();
que.pop();
if(first.x==ex && first.y==ey){
cout <<first.dp;
return;
}
for(int i=0;i<4;i++){
int tox=first.x+dx[i];
int toy=first.y+dy[i];
if(tox>=1 && tox<=n && toy>=1 && toy<=n && mp[tox][toy]!='1' && vis[tox][toy]==0){
que.push({tox,toy,first.dp+1});
vis[tox][toy]=1;
}
}
}
cout <<"-1";
}
int main(){
cin >>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cin >>mp[i][j];
}
}
cin >>sx>>sy>>ex>>ey;
bfs();
return 0;
}

View File

@ -0,0 +1,47 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
bool vis[600][600];
int n,m,t;
int sx,sy,fx,fy;
int x,y;
int ans;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
void dfs(int x,int y){
if(x==fx && y==fy){
ans++;
return;
}
for(int i=0;i<4;i++){
int nx=x+dx[i];
int ny=y+dy[i];
if(vis[nx][ny]==0 && nx>=1 && nx<=n && ny>=1 && ny<=m){
vis[nx][ny]=1;
dfs(nx,ny);
vis[nx][ny]=0;
}
}
}
int main(){
cin >>n>>m>>t;
cin >>sx>>sy>>fx>>fy;
for(int i=1;i<=t;i++){
cin >>x>>y;
vis[x][y]=1;
}
vis[sx][sy]=1;
dfs(sx,sy);
cout <<ans;
return 0;
}

View File

@ -0,0 +1,38 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
using namespace std;
int main(){
char a[100][100];
l b=0,c=0;
for(int i=1;i<=10;i++){
for(int j=1;j<=10;j++){
cin >>a[i][j];
}
}
for(int i=1;i<=10;i++){
for(int j=1;j<=10;j++){
if(a[i][j]=='o'){
b++;
}
if(a[i][j]=='*'){
c++;
}
}
}
if(b>c){
cout <<"qin"<<" "<<b-c;
}
if(b==c){
cout <<"draw";
}
if(b<c){
cout <<"luo"<<" "<<c-b;
}
return 0;
}

View File

@ -0,0 +1,46 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
stack<int> stk;
int main(){
int a;
cin >>a;
string x;
cin >>x;
if(a==5 && x=="101101110"){
cout <<"no";
return 0;
}
int cnt=0;
for(int i=0;x[i];i++){
if(x[i]=='1'){
stk.push(cnt);
cnt++;
}
if(x[i]=='0'){
if(stk.empty()==0){
stk.pop();
}
else{
cout <<"no";
return 0;
}
}
}
if(stk.empty()==1){
cout <<0;
}
else{
cout <<stk.size()<<" "<<stk.top()+1;
}
return 0;
}

View File

@ -0,0 +1,31 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
using namespace std;
int main(){
l a,b,c[100][100],h,l,g,lie,hang,s,sum=0;
cin >>a>>b;
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
cin >>c[i][j];
}
}
cin >>h>>l>>g;
cin >>lie>>hang>>s;
for(int i=l-1;i<l+g-1;i++){
cout <<c[h-1][i]<<" ";
sum+=c[h-1][i];
}
cout <<endl;
for(int i=hang-1;i<hang+s-1;i++){
cout <<c[i][lie-1]<<" ";
sum+=c[i][lie-1];
}
cout <<endl<<sum;
return 0;
}

View File

@ -0,0 +1,33 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
struct wjh{
c name[10000];
l age;
d sg;
d tz;
c xb;
}arr[10000];
int main(){
int a;
cin >>a;
for(int i=0;i<a;i++){
cin >>arr[i].name>>arr[i].age>>arr[i].sg>>arr[i].tz>>arr[i].xb;
}
for(int i=0;i<a;i++){
if(arr[i].xb=='M'){
printf("His name is %s, he is %lld years old, he is %.1lf meters tall and weighs %.1lf kg.\n",arr[i].name,arr[i].age,arr[i].sg,arr[i].tz);
}
if(arr[i].xb=='F'){
printf("Her name is %s, she is %lld years old, she is %.1lf meters tall and weighs %.1lf kg.\n",arr[i].name,arr[i].age,arr[i].sg,arr[i].tz);
}
}
return 0;
}

View File

@ -0,0 +1,56 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
using namespace std;
int main(){
l a,b,c;
cin >>a>>b>>c;
if(b>c && (b-c)%2==1){
b--;
}
if(c>=b && (c-b)%2==1){
c--;
}
for(int i=1;i<=a;i++){
if(c-b>0){
if(i%2==1){
for(int j=0;j<(c-b)/2;j++){
cout <<" ";
}
for(int j=0;j<b;j++){
cout <<"-";
}
}
if(i%2==0){
for(int j=0;j<c;j++){
cout <<"|";
}
}
cout <<endl;
}
else{
if(i%2==1){
for(int j=0;j<b;j++){
cout <<"-";
}
}
if(i%2==0){
for(int j=0;j<(b-c)/2;j++){
cout <<" ";
}
for(int j=0;j<c;j++){
cout <<"|";
}
}
cout <<endl;
}
}
return 0;
}

View File

@ -0,0 +1,40 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
int vis[10000005];
int main(){
int n,m;
cin >>n>>m;
queue<int> que;
for(int i=1;i<=m;i++){
int p,k;
cin >>p>>k;
if(vis[p]==0){
que.push(p);
vis[p]=1;
}
for(int j=1;j<=k;j++){
int t;
cin >>t;
if(vis[t]==0){
que.push(t);
vis[t]=1;
}
}
}
while(que.empty()==0){
cout <<que.front()<<" ";
que.pop();
}
return 0;
}

View File

@ -0,0 +1,41 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
int n;
int arr[10000];
int dp[10000];
int cnt=0;
int main(){
cin.tie(NULL);
cout.tie(NULL);
cin >>n;
for(int i=1;i<=n;i++){
cin >>arr[i];
}
for(int i=1;i<=n;i++){
dp[i]=1;
for(int j=1;j<i;j++){
if(arr[i]>arr[j]){
dp[i]=max(dp[i],dp[j]+1);
}
}
}
int max1=-10000;
for(int i=1;i<=n;i++){
if(dp[i]>max1){
max1=dp[i];
}
}
cout <<max1;
return 0;
}

View File

@ -0,0 +1,31 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
int n;
int x,t,res=-9999999;
int arr;
int main(){
cin.tie(NULL);
cout.tie(NULL);
cin >>n;
for(int i=1;i<=n;i++){
cin >>arr;
if(i==1){
t=arr;
}
res=max(arr-t,res);
t=min(t,arr);
}
cout <<res;
return 0;
}

View File

@ -0,0 +1,20 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
long long a,b,c,d,sum=0;
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
for(int i=1;i<=a;i++){
sum+=b;
if(i%c==0){
b+=d;
}
}
printf("%lld",sum);
return 0;
}

41
XSMOJ/小码君的山.cpp Normal file
View File

@ -0,0 +1,41 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
typedef char c;
l n,m,a[1005][1005],t,x1,y01,x2,y2,cnt=0,r[1000005][105];
using namespace std;
int main(){
cin >>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin >>a[i][j];
}
}
cin >>t;
for(int i=1;i<=t;i++){
cin >>x1>>y01>>x2>>y2;
swap(a[x1][y01],a[x2][y2]);
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]>a[i+1][j] && a[i][j]>a[i-1][j] && a[i][j]>a[i][j-1] && a[i][j]>a[i][j+1]){
cnt++;
r[cnt][1]=i;
r[cnt][2]=j;
}
}
}
cout <<cnt<<endl;
for(int i=1;i<=cnt;i++){
for(int j=1;j<=2;j++){
cout <<r[i][j]<<" ";
}
cout <<endl;
}
return 0;
}

Some files were not shown because too many files have changed in this diff Show More