5 条题解

  • 2
    @ 2023-10-27 21:19:19

    QidOnG!!

    #include<bits/stdc++.h>
    int main(){   
        int m,i,a[1000],x,t,j;
        x=0;
        scanf("%d",&m);
        for(i=1; i<=m; i++){
            scanf("%d",&a[i]);
        }
        for(i=1; i<=m; i++){   
            a[i]=a[i]-a[i+1];
            if(a[i]<0){
                a[i]=-a[i];
            }
        }
        for(i=1; i<=m-1; i++){   
            for(j=1; j<=m-i; j++){   
                if(a[j]>a[j+1]){
                    t=a[j];
                    a[j]=a[j+1];
                    a[j+1]=t;
                }
            }
        }
        for(i=1; i<=m; i++){
            if(a[i]==i) x++;
        }
        if(m-1==x){
            printf("Jolly");
        }
        else printf("Not jolly");
        return 0;
    }
    
    • 1
      @ 2023-11-2 18:07:12
      #include<bits/stdc++.h>
      using namespace std;
      int a[1003],b[1002];
      int main()
      {
          int n;cin >> n;
          for(int i=1;i<=n;i++)
              cin >> a[i];
          for(int i=1;i<n;i++)
              b[i] = abs(a[i+1]-a[i]);
          sort(b+1,b+n);
          for(int i=1;i<n;i++)
          {
              if(b[i] != i)
              {
                  cout << "Not jolly" ;
                  return 0;
              }
          }  
          cout << "Jolly";
          return 0;
      }
      
      • 1
        @ 2023-10-27 22:28:35
        #include <bits/stdc++.h>
        int main(){
            int n,a[1005]; std::cin>>n;
            for(int i=0;i<n;i++)std::cin>>a[i];
            for(int i=0;i<n;i++)a[i]=abs(a[i]-a[i+1]);
            std::sort(a,a+n);
            for(int i=0;i<n-1;i++)
                if(a[i]!=i+1){
                    std::cout<<"Not jolly";
                    return 0;}   
            std::cout<<"Jolly"; return 0;}
        
        • 1
          @ 2023-10-27 14:06:16
          #include<bits/stdc++.h>
          using namespace std;
          int a[1010],b[1010];
          int main(){
          	int n,maxn,minn;
          	cin>>n;
          	for(int i=1;i<=n;i++){
          		cin>>a[i];
          	}
          	for(int i=1;i<n;i++){
          		b[i]=abs(a[i]-a[i+1]);
          	}
          	/*
          	for(int i=1;i<n;i++){
          		cout<<b[i]<<" ";
          	}
          	cout<<endl;*/
          	maxn=b[1];
          	minn=b[1];
          	for(int i=2;i<n;i++){
          		if(b[i]>maxn)	maxn=b[i];
          		if(b[i]<minn)	minn=b[i];
          	}
          	//cout<<maxn<<" "<<minn<<endl;
          	if(maxn-minn==n-2)	cout<<"Jolly";
          	else cout<<"Not jolly";
          	return 0;
          }
          
          • 0
            @ 2023-12-9 20:38:29
            #include<bits/stdc++.h>
            using namespace std;
            int main()
            {
                int a[1005],b[1005],n;
                cin>>n;
                for(int i=1;i<=n;i+=1)cin>>a[i];
                for(int i=1;i<=n-1;i+=1)b[i]=abs(a[i+1]-a[i]);
                sort(b+1,b+n);
                for(int i=1;i<=n-1;i+=1)
                {
                    if(b[i]!=i)
                    {
                        cout<<"Not jolly";
                        return 0;
                    }
                }
                cout<<"Jolly";
            }
            
            • 1

            信息

            ID
            525
            时间
            1000ms
            内存
            256MiB
            难度
            6
            标签
            递交数
            1251
            已通过
            428
            上传者