洛谷题目
wang_hua_yi
这个作者很懒,什么都没留下…
展开
-
P1036_选数
#include <bits/stdc++.h>using namespace std;const int N=5000005;int A[N];//质数数组 int T[N];//打表 int X[N];//输入的数字 int cn=0;int n,k,sum=0,cnt=0;void init(){ A[cn++]=2; int a=2; while(1){ for(int x=a;x<N;x+=a)T[x]=1; for(int x=a+1;;x++.原创 2022-01-27 23:52:44 · 235 阅读 · 0 评论 -
洛谷题目《合并果子》代码实现
参考网址https://www.luogu.com.cn/problem/P1090#include<iostream>using namespace std;//《合并果子》//https://www.luogu.com.cn/problem/P1090//a[i]==0 表示水果已经合并了void getMin(int n,int a[],int &minIndex,int &minValue){ //取第一个值非0值 for(int i=0;i<原创 2021-10-10 15:08:51 · 234 阅读 · 0 评论 -
洛谷题目《黑白图像压缩》
参考网址https://www.luogu.com.cn/problem/P2556#include<iostream>#include<stdio.h>using namespace std;//处理中中间的位图(补充说明:题目中提到连续1或0的个数不超过128即可以用7个位来存,所以不用考虑count>128的情况)void HandleBitMap(unsigned char &x,unsigned char &head,unsigned原创 2021-10-10 15:00:02 · 137 阅读 · 0 评论 -
洛谷题目《排队接水》代码实现
参考网址https://www.luogu.com.cn/problem/P1223我的代码#include<iostream>#include<stdio.h>using namespace std;void exchange(double &a,double &b){ double t=a; a=b; b=t;}void sort(int n,double a[][3]){ for(int i=0;i<n-1;i++) {原创 2021-10-10 14:32:17 · 142 阅读 · 0 评论 -
2021-10-10 洛谷题目《国王的游戏》代码实现
洛谷题目《国王的游戏》代码实现题目描述恰逢 HH国国庆,国王邀请nn 位大臣来玩一个有奖游戏。首先,他让每个大臣在左、右手上面分别写下一个整数,国王自己也在左、右手上各写一个整数。然后,让这 nn 位大臣排成一排,国王站在队伍的最前面。排好队后,所有的大臣都会获得国王奖赏的若干金币,每位大臣获得的金币数分别是:排在该大臣前面的所有人的左手上的数的乘积除以他自己右手上的数,然后向下取整得到的结果。国王不希望某一个大臣获得特别多的奖赏,所以他想请你帮他重新安排一下队伍的顺序,使得获得奖赏最多的大臣,所获奖原创 2021-10-10 08:57:55 · 190 阅读 · 0 评论