当前位置:网站首页>The fifth day of the third question of Luogu daily
The fifth day of the third question of Luogu daily
2022-07-19 03:28:00 【Xiao Tang (๑ & gt; & lt; ๑)】
Catalog
P1271 【 Deep base 9. example 1】 Election of Student Union
P1059 [NOIP2006 Popularization group ] A clear random number
P1321 Word overlay restore
Title Description
A length of ll Is repeatedly pasted with
boyandgirlTwo words , The post pasted words may cover the pasted words ( What is not covered is represented by a period ), Eventually, at least one character per word is not covered . How many are thereboyHow many?girl?Input format
A line is repeatedly pasted with
boyandgirlTwo word string .Output format
Two lines , Two integers . First act
boyThe number of , Second behaviorgirlThe number of .I/o sample
Input #1 Copy
......boyogirlyy......girl.......Output #1 Copy
4 2explain / Tips
Data assurance ,3\le l\le2553≤l≤255, The string contains only the following characters :\texttt{.bgilory}.bgilory.
# include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int blp=-1;
int count0=0;
int count1=0;
for(int i=0;i<s.length();i++)
{
if (s[i]=='b'||s[i+1]=='o'||s[i+2]=='y')
{
count0++;
}
if (s[i]=='g'||s[i+1]=='i'||s[i+2]=='r'||s[i+3]=='l')
{
count1++;
}
}
cout<<count0<<endl<<count1;
}P1271 【 Deep base 9. example 1】 Election of Student Union
Title Description
The school is electing members of the student union , Yes n(n\le 999)n(n≤999) Nominee , Each candidate is numbered from 1 To nn, Now I have collected m(m<=2000000)m(m<=2000000) votes , Each ballot is marked with a candidate number . Now I want to sort these mountains of votes according to the number of votes from small to large .
Input format
Input nn and mm as well as mm A number on a ballot .
Output format
Find the sorted ballot number .
I/o sample
Input #1 Copy
5 10 2 5 2 2 5 2 2 2 1 2Output #1 Copy
1 2 2 2 2 2 2 2 5 5
# include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int a[m];
for(int i=0;i<m;i++)
{
cin>>a[i];
}
sort(a,a+m);
for(int i=0;i<m;i++)
{
cout<<a[i]<<" ";
}
} P1059 [NOIP2006 Popularization group ] A clear random number
Title Description
I want to invite some students to do a questionnaire survey at school , For the objectivity of the experiment , He first generated... By computer NN individual 11 To 10001000 Random integer between (N\leq100)(N≤100), For the repeated numbers , Keep only one , Take out the rest of the same number , Different numbers correspond to different student numbers . And then sort the numbers from small to large , According to the order of arrangement to find students to do research . Please help Mingming finish “ duplicate removal ” And “ Sort ” The job of .
Input format
There are two lines of input , The first 11 Behavior 11 A positive integer , Represents the number of generated random numbers NN.
The first 22 Yes NN Positive integers separated by spaces , For the resulting random number .
Output format
Output is also two lines , The first 11 Behavior 11 A positive integer MM, The number of different random numbers .
The first 22 Behavior MM Positive integers separated by spaces , Different random numbers in order from small to large .
I/o sample
Input #1 Copy
10 20 40 32 67 40 20 89 300 400 15Output #1 Copy
8 15 20 32 40 67 89 300 400explain / Tips
NOIP 2006 Popularization group The first question is
# include <stdio.h>
# include <stdlib.h>
//int cmp(int *x, int *y) {
// return *x - *y;
//}
int comp(const void *a,const void *b)
{
return *(int *)a-*(int *)b;
}
int main()
{
int n;scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
// a[i]=rand()%1000+1;
// printf("%d ",a[i]);
}
//int count=0;
qsort(a,n,sizeof(int),comp);
// for(int i=0;i<n;i++)
// {
// printf("%d ",a[i]);
// }
int b[n];
int j=0;
for(int i=1;i<n;i++)
{
if(a[i]==a[i-1])
{
continue;
}
b[j]=a[i-1];
j++;
}
if(a[n-1]!=a[n-2])
{
b[j]=a[n-1];
j++;
}
printf("%d\n",j);
for(int i=0;i<j;i++)
{
printf("%d ",b[i]);
}
return 0;
} 边栏推荐
- Can't access this website can't find DNS address DNS_ PROBE_ What about started?
- 2002 - Can‘t connect to server on ‘127.0.0.1‘ (36)
- Wechat applet
- In depth understanding of machine learning - unbalanced learning: sample sampling technology - [adasyn sampling method of manual sampling technology]
- MySQL interview questions (2022)
- oracle 查询非自增长分区的最大分区
- leetcode162. 寻找峰值
- 自动装配 & 集合注入
- Net SNMP development I
- 重写equals为什么要重写hashcode
猜你喜欢

基于MFC如何实现单个文档的文件读写

代理模式——B站动力节点

By voting for the destruction of STI by Dao, seektiger is truly community driven

First knowledge of JPA (ORM idea, basic operation of JPA)

Zabbix6.0 monitoring vcenter7.0

Pytorch best practices and code templates

Basic IDL content of note 1: common data types_ Create array_ Type conversion_ Print output_ Basic operation_ Relational operation

通过OpenHarmony兼容性测评,大师兄开发板与丰富教培资源已ready

数据源对象管理(第三方对象资源) & 加载properties文件
![In depth understanding of machine learning - unbalanced learning: sample sampling technology - [smote sampling method and borderline smote sampling method of manual sampling technology]](/img/9f/a0d03b23e66849f12150f9a72f36c5.png)
In depth understanding of machine learning - unbalanced learning: sample sampling technology - [smote sampling method and borderline smote sampling method of manual sampling technology]
随机推荐
MySQL multi table query
Yolov5 opencv DNN reasoning
Envi: (the most detailed tutorial in 2022) custom coordinate system
Latest installation tutorial of VMware Tools (rhel8)
Ubuntu clear CUDA cache
Backup kubernetes backup etcd data
Wdog and power mode of fs32k148 commissioning
Zabbix6.0 monitoring vcenter7.0
Wechat applet
Dqn theoretical basis and code implementation [pytoch + cartpole-v0]
leetcode 222. 完全二叉树的节点个数(必会)
MySQL optimized index
Automatic assembly & set injection
D. Permutation restoration (greedy / double pointer /set)
In depth understanding of machine learning - unbalanced learning: sample sampling technology - [smote sampling method and borderline smote sampling method of manual sampling technology]
Zabbix6.0 monitors Dell and IBM server hardware through Idrac and imm2
It's good to take more exercise
Net SNMP related commands
Browser cannot open tensorboard
Several methods of face detection