31 条题解

  • -3
    @ 2024-1-20 16:03:44
    #include <bits/stdc++.h>
    #include <cstring>
    using namespace std;
    int main(){
        string str;
        int arr[26]={0};
        getline(cin,str);
        for(int i=0;str[i];i++){
    		if(str[i]>='a' && str[i]<='z')
    			str[i]-=32; 
    	}
    	for(int i=0;str[i];i++){
    	    if(str[i]>='A' && str[i]<='Z')
    			arr[str[i]-'A']+=1;	
    	}
    	int max=arr[0];
    	for(int i=0;i<26;i++){
    		if(arr[i]>max)
    		max=arr[i];
    	}
    	for(int i=1;i<=max;i++){
    	    for(int j=0;j<26;j++){
    	        if(max-i<arr[j])
    	        	cout<<"*";
    	        else
    	            cout<<" ";
    	        if(j!=25)
    	            cout<<" ";
    		}
    		cout<<endl;	
    	}
    	for(int i=0;i<26;i++){
    		cout<<char(i+'A');
    		if(i!=25) cout<<" ";
    	}
        return 0;	
    }
    
    • -3
      @ 2024-1-7 11:47:41
      #include <bits/stdc++.h>
      using namespace std;
      int main(){
         	int n,arr[105],k=0;
         	cin>>n;
         	for(int i=1;i<=n;i++){
         		cin>>arr[i];
      	}
      
      	for(int i=1;i<=n;i++){
      		int a,b,c,d,m;
      		a=arr[i]/1000;
      		b=arr[i]/100%10;
      		c=arr[i]/10%10;
      		d=arr[i]%10;
      		m=d-b-c-a;
      		if(m>0) k++;
      	} 
      	cout<<k;
          return 0;
      }
      
      • -3
        @ 2023-12-31 10:38:07

        #include <bits/stdc++.h> using namespace std; int main(){ int a,b,c; cin>>a>>b>>c; if(a>=10000){ if(b>800 || c>900){ cout<<"Yes"<<endl; } else{ cout<<"No"<<endl; } } else{ cout<<"No"; } return 0; }

        • -3
          @ 2023-12-10 9:53:07

          #include #include using namespace std; struct jyd{ double weight,value,v; }arr[4]; bool cmp(jyd a,jyd b){ return a.v>b.v; } int main(){ for(int i=0;i<4;i++){ cin>>arr[i].weight>>arr[i].value; arr[i].v=arr[i].value/arr[i].weight; } sort(arr,arr+4,cmp); double n=300,s=0; for(int i=0;i<4;i++){ if(n>=arr[i].weight) s = s+arr[i].value; else s = s+arr[i].vn; n = n-arr[i].weight; if(n<=0) break; } cout<<s; return 0 ; } / 180 208 208 520 50 210 */

          • -4
            @ 2024-3-10 11:00:36
            #include <bits/stdc++.h>
            using namespace std;
            int main(){
            	int a,b,c,cnt=0;
            	cin>>a>>b>>c;
            	if(b>=c){
            		cnt += b-c+1;
            		b = c-1;
            	}
            	if(a>=b){
            		cnt+= a-b+1;
            		a=b-1;
            	}
            	if(a>0)
            		cout<<cnt;
            	else
            		cout<<-1;	
            	return 0;
            }
            
            • -4
              @ 2024-3-10 11:00:22

              #include<bits/stdc++.h> using namespace std; int a[10][110]; int res[11000]; int main(){ int n;cin>>n; int mx=0; for(int i=1;i<=n;i++){ cin>>res[i]; int x=res[i]; int c=0; while(x){ x/=10; c++; } mx=max(mx,c); int cc=1; for(int i=1;i<mx;i++){ for(int j=1;j<=n;j++){ int x=res[j]; x/=cc; a[x%10][0]++; a[x%10][a[x%10][0]]=res[j]; } int idx=1; for(int j=0;j<10;j++){ for(int k=1;k<=a[j][0];k++){ res[idx]=a[j][k]; idx++; } a[j][0]=0 } cc*=10

              }
              }
              for(int i=1;i<=n;i++) cout<<res[i]<<" ";
              return 0;
              

              }

              • -4
                @ 2024-3-10 11:00:15

                *#include using namespace std; const int N = 1e5+10; int a[N],cnt[N]; int main(){ int n,c;cin>>n>>c; for(int i=1;i<=n;i++) { cin>>a[i]; cnt[a[i]]++; } int res=0; for(int aa=0;aa<100000;aa++) { int b = aa-c; if(b<0) continue; res+=cnt[aa]*cnt[b]; } cout<

                • -4
                  @ 2024-3-3 11:26:58
                  #include<bits/stdc++.h> 
                  using namespace std; 
                  int cnt[26]; 
                  int main(){ 
                  	string s;
                  	getline(cin,s);
                  	for(int i=0;i<s.size();i++){
                  		if(s[i]>='a'&&s[i]<='z'){
                  			s[i]-=32;
                  		}
                  		if(s[i]>='A'&&s[i]<='Z'){
                  			cnt[s[i]-'A']++;
                  		}
                  	}
                  	for(int i=0;i<26;i++){
                  		cout<<char(i+'A')<<":";
                  		for(int j=1;j<=cnt[i];j++){
                  			cout<<"*"; 
                  		}
                  		cout<<endl; 
                  	}
                  }
                  
                  
                  
                  
                  • -4
                    @ 2023-12-10 9:52:40

                    #include #include using namespace std; struct jyd{ double weight,value,v; }arr[4]; bool cmp(jyd a,jyd b){ return a.v>b.v; } int main(){ for(int i=0;i<4;i++){ cin>>arr[i].weight>>arr[i].value; arr[i].v=arr[i].value/arr[i].weight; } sort(arr,arr+4,cmp); double n=300,s=0; for(int i=0;i<4;i++){ if(n>=arr[i].weight) s = s+arr[i].value; else s = s+arr[i].vn; n = n-arr[i].weight; if(n<=0) break; } cout<<s; return 0 ; } / 180 208 208 520 50 210 */

                    • -5
                      @ 2024-3-31 15:37:44
                      #include<bits/stdc++.h>
                      using namespace std;
                      int main(){
                      	int n;
                      	cin>>n;
                      	int m[1000]={0};
                      	m[0]=1;
                      	m[1]=2;
                      	for(int i=1;i<=n;i++){
                      		m[i]=m[i-1]+m[i-2];
                      	}
                      	cout<<m[n];
                      	return 0;
                      }
                      
                      
                      • -5
                        @ 2024-3-31 15:36:58
                        #include <bits/stdc++.h>
                        using namespace std; 
                        long long arr[1000000]={0,1,2}; 
                        int main(){ 
                        	int n; 
                        	cin>>n; 
                        	for(int i=3;i<=1000000;i++){ 
                        	arr[i] = (2*arr[i-1]+arr[i-2])%32767; 
                        	}
                        	for(int i=1;i<=n;i++){
                        		int k; 
                        		cin>>k;
                        		cout<<arr[k]<<endl; 
                        	}
                        return 0;
                        }
                        

                        信息

                        ID
                        1
                        时间
                        1000ms
                        内存
                        256MiB
                        难度
                        4
                        标签
                        递交数
                        44
                        已通过
                        21
                        上传者