1、3341:练58.1 严格排名
/*
3341:练58.1 严格排名
http://bas.ssoier.cn:8086/problem_show.php?pid=3341
*/
#include <bits/stdc++.h>
using namespace std;
long long a[100000+10],n,k;
int main()
{
cin>>n>>k;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
unique(a,a+n);
cout<<a[k-1];
return 0;
}
2、3342:【例59.1】 合并果子
[例59.1] 合并果子
1369:合并果子(fruit)
1836:【04NOIP提高组】合并果子
/*
1836:【04NOIP提高组】合并果子02--STL
http://ybt.ssoier.cn:8088/problem_show.php?pid=1836
https://www.cnblogs.com/shadowland/p/5870374.html
https://blog.csdn.net/qq_35546304/article/details/51992911
https://blog.csdn.net/o_0Freshman0_o/article/details/88364681
*/
#include <bits/stdc++.h>
#define maxN 100010
using namespace std;
typedef long long QAQ ;
int arr[maxN];
priority_queue<int ,vector<int>,greater<int> >Q;
QAQ ans ;
int main(){
int n,tmp2,tmp1;
ios::sync_with_stdio(false);
cin >> n ;
for(int i=1 ; i<=n ;++i)cin >> arr[i];
sort(arr+1,arr+n+1);;//对数据先排序,防止优先队列超时
for(int i=1;i<=n;++i){
Q.push(arr[i]);
}
for(int i=1;i<=n-1;++i)
{
tmp1=Q.top();
Q.pop();
tmp2=Q.top();
Q.pop();
Q.push(tmp1+tmp2);
ans+=tmp1+tmp2;
}
printf("%lld",ans);
return 0 ;
}
3、3343:练59.1 第n大的数
练 59.1 第n大的数
1176:谁考了第k名
一本通视频题解——1176:谁考了第k名
一本通视频题解——1176:谁考了第k名_哔哩哔哩_bilibili
谁考了第k名(信息学奥赛一本通-T1176)_哔哩哔哩_bilibili
1235:输出前k大的数
NOIP 2008 普及组初赛试题完善程序 4.2 (找第k大的数)
/*
3343:练59.1 第n大的数
http://bas.ssoier.cn:8086/problem_show.php?pid=3343
*/
#include <bits/stdc++.h>
using namespace std;
int maxn(int b[],int m)
{
bool p=true;
int x,num,cnt,i=0;
while( p && i<10 )
{
x=b[i];
num=cnt=0;
for(int j=0;j<10;j++)
{
if( x<b[j] )
{
num++;
}
else
{
if( x==b[j] )
{
++cnt;
}
}
}
if( num+1<=m && num+cnt>=m )
{
p=false;
}
else
{
i++;
}
}
return x;
}
int main( )
{
int n,a[10]={99,200,95,87,98,-12,30,87,75,-25};
do
{
cin>>n;
}while( n<1 || n>10);
cout<<maxn(a,n)<<endl;
return 0;
}
4、3344:【例60.1】 整数去重
/*
1.9编程基础之顺序查找_13整数去重02
http://noi.openjudge.cn/ch0109/13/
*/
#include<iostream>
using namespace std;
int a[10010],n,x,sum;
int main( void )
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>x;
if(a[x]==0)
cout<<x<<" ";
a[x]++;
}
return 0;
}
5、3345:【例60.2】 约瑟夫问题
/*
P1996 约瑟夫问题
https://www.luogu.com.cn/problem/P1996
*/
#include<bits/stdc++.h>
using namespace std;
queue <int> q;
int n,m,i;
int main() {
for(scanf("%d%d",&n,&m),i=1; i<=n; i++) q.push(i);
while( !q.empty() )
{
for(i=1; i<m; i++) q.push(q.front()),q.pop();
printf("%d ",q.front()),q.pop();
}
return 0;
}
6、3346:【例60.3】 找素数
#include <bits/stdc++.h>
using namespace std;
int z(int x)
{
if(x==1) return 1;
int t=sqrt(x);
for(int i=2;i<=t;i++){
if(x%i==0) return 0;
}
return 1;
}
int main()
{
int a,b;
cin>>a>>b;
for(int i=a;i<=b;i++){
if(z(i)) cout<<i<<endl;
}
return 0;
}
7、3347:练60.1 丢失的数字
#include <bits/stdc++.h>
using namespace std;
int a[100000],n,m,t;
int main()
{
cin>>n>>m;
for(int i=1;i<=m;i++){
scanf("%d",&t);
a[t]=1;
}
for(int i=1;i<=n;i++){
if(!a[i]) printf("%d\n",i);
}
return 0;
}
8、3348:练60.2 众数
#include <stdio.h>
#include <string.h>
#define N 1000
int count[N+1];
int main(void)
{
int n, val, i;
memset(count, 0, sizeof(count));
scanf("%d", &n);
for(i=1; i<=n; i++) {
scanf("%d", &val);
count[val]++;
}
int max = count[0], ans=0;
for(i=1; i<=N; i++)
if(count[i] > max) {
max = count[i];
ans = i;
}
printf("%d\n", ans);
return 0;
}
9、3349:练60.3 余数个数
/*
3349:练60.3 余数个数
http://bas.ssoier.cn:8086/problem_show.php?pid=3349
https://blog.csdn.net/ptyz306/article/details/133549340
*/
#include<bits/stdc++.h>
using namespace std;
bool bj[50];
int main(){
long long a[11];
for(int i=1;i<=10;i++){
cin>>a[i];
int ls=a[i]%42;
bj[ls]=1;
}
long long cnt=0;
for(int i=0;i<=42;i++){
if(bj[i]==1){
cnt++;
}
}
cout<<cnt;
return 0;
}
10、3350:练60.4 捉迷藏
/*
第62课 捉迷藏
山上有10个山洞。
10-1--3--6---10
1000次
试编一程序,算一算,兔子尼克躲在几号洞里。
*/
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
bool a[11];
int i,cishu;
//第i个洞没有进
for(i=1;i<=10;i++)
a[i]=true;
i=0;
cishu=1;
//cout<<"first i="<<i<<" cishu="<<cishu<<endl;
while(cishu<=100)
{
//cout<<"000i="<<i<<endl;
i=(i+cishu)%10;
if(i==0)
{
//cout<<"i=0 cishu="<<cishu<<endl;
i=10;
}
a[i]=false;
//cout<<"i="<<i<<endl;
cishu++;
//cout<<"-------------------"<<endl;
}
for(i=1;i<=10;i++)
if( a[i] ) cout<<i<<endl;
return 0;
}
/*
作业:
2037:【例5.4】约瑟夫问题
http://ybt.ssoier.cn:8088/problem_show.php?pid=2037
2038:【例5.5】最大数位置
http://ybt.ssoier.cn:8088/problem_show.php?pid=2038
2039:【例5.6】冒泡排序
http://ybt.ssoier.cn:8088/problem_show.php?pid=2039
*/
1、少儿编程(c++)解奥数题目(6集)
2、少儿编程(c++)少儿编程教育(56集)
3、每天五分钟学会C++(105集)
4、《小学生C++趣味编程》(11集)
5、少儿C++编程(26集)
6、精简版c++编程入门+配套练习(42集)
7、c++编程(11集)
8、小学生C++趣味编程(3集)
9、C++编程入门宝典:从零基础(4集)
10、从零开始学习C++编程(36集)
https://www.douyin.com/video/7051102938487426334