跳到正文

个人记录

桶

__QianXiao__约 4 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 4 分钟

版本

  1. v2当前
  2. v1

P1598-垂直柱状图

C
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define re return
#define ew 5005
#define sz 10000005
#define sscc cout<<6;
const int MOD=1e9+7;
int tong[50];
char mp[50][50];
int maxx=-2e9;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	char c;
	while(cin>>c){
		if(c>='A' && c<='Z'){
			tong[c-'A'+1]++;
		}
	}
	for(int i=1;i<=40;i++){
		for(int j=1;j<=40;j++){
			mp[i][j]=' ';
		}
	}
	for(int i=1;i<=26;i++){
		maxx=max(maxx,tong[i]);
	}
	/*
	for(int i=1;i<=26;i++){
		cout<<tong[i]<<endl;
	}
	cout<<maxx;
	*/
	for(int i=maxx;i>=1;i--){
		for(int j=1;j<=26;j++){
			if(tong[j]>=i){
				cout<<"*"<<" ";
			}
			else{
				cout<<"  ";
			}
		}
		cout<<endl;
	}
	for(int i=1;i<=26;i++){
		cout<<char(i+64)<<" ";
	}
	re 0;
}






/*
                            *
                            *
        *                   *
        *                   *     *   *
        *                   *     *   *
*       *     *             *     *   *
*       *     * *     * *   *     * * *
*       *   * * *     * *   * *   * * * *
*     * * * * * *     * * * * *   * * * *     * *
* * * * * * * * * * * * * * * * * * * * * * * * * *
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

*/

P1138-第 k 小整数

C
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define re return
#define ew 5005
#define sz 10000005
#define sscc cout<<6;
const int MOD=1e9+7;
int tong[sz];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,k;
	cin>>n>>k;
	int x;
	for(int i=1;i<=n;i++){
		cin>>x;
		tong[x]++;
	}
	/*
	for(int i=1;i<=n;i++){
		cout<<tong[i]<<" ";
	}
	*/
	int y=0;
	for(int i=1;i<=10000;i++){
		if(tong[i]!=0){
			y++;
		}
		if(y==k){
			cout<<i;
			re 0;
		}
	}
	cout<<"NO RESULT";
	re 0;
}
原文