7-1 520表白

不用说

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 1e9;
const int maxm = 1e5 + 5;
const int inf = 2147483647;
using namespace std; int solve(){
int n, m;
cin >> n;
cout << n << "! " << "520!";
return 0;
} int main() {
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}

7-2 分糖豆

不用说

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 1e9;
const int maxm = 1e5 + 5;
const int inf = 2147483647;
using namespace std; int solve(){
int n, m, k;
cin >> n >> m >> k;
if(n * k == m){
cout << "zheng hao mei ren " << k << "!";
}else if(n * k < m){
cout << "hai sheng " << m - n * k << "!";
}else cout << "hai cha " << n * k - m << "!";
return 0;
} int main() {
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}

7-3 约会App

判断下就可以,不用说

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 1e9;
const int maxm = 1e5 + 5;
const int inf = 2147483647;
using namespace std; int solve(){
int x, a, b, c, d, n;
cin >> x >> a >> b >> c >> d >> n;
while(n--){
int s, y, h;
cin >> s >> y >> h;
if(s != x && y >= a && y <= b && h >= c && h <= d){
cout << s << ' ' << y << ' ' << h << "\n";
}
}
return 0;
} int main() {
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}

7-4 关于奇数的等式

范围小从1开始找就行,根据等式判断

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 1e9;
const int maxm = 1e5 + 5;
const int inf = 2147483647;
using namespace std; int solve(){
int n, m, x, y, z, f = 0;
cin >> n >> m;
for(int i = 1; i <= m - 4; i += 2){
for(int j = i + 2; j <= m - 2; j += 2){
for(int k = j + 2; k <= m; k += 2){
if((1.0 * 3 / n) == ((1.0 / i) + (1.0 / j) + (1.0 / k))){
f = 1;
cout << i << ' ' << j << ' ' << k;
return 0;
}
}
}
}
if(!f)cout << "No solution in (3, " << m << "].";
return 0;
} int main() {
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}

7-5 我侬数

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 1e9;
const int maxm = 1e5 + 5;
const int inf = 2147483647;
using namespace std; int aa[10], cc[10];//分别是存 原本基础数 和 需要判断的数 的0-9的个数 int solve(){
string a, b, c, d;
cin >> a >> b;
int i = 0, j = 0, p = 0;
//去掉前面0
while(a[i] == '0' && i < a.length())i++;
while(b[j] == '0' && j < b.length())j++; //找0-9的个数
while(i < a.length())aa[a[i] - '0']++, i++;
while(j < b.length())aa[b[j] - '0']++, j++; while(1){
for(int k = 0; k < 10; k ++)cc[k] = 0;//每次都要重新清0
cin >> c >> d;
if(c == "0" && d == "0")break; //同上
i = 0, j = 0;
while(c[i] == '0' && i < c.length())i++;
while(d[j] == '0' && j < d.length())j++;
while(i < c.length())cc[c[i] - '0']++, i++;
while(j < d.length())cc[d[j] - '0']++, j++; int f = 0;
for(int k = 0; k < 10; k++){
//有不一样就No
if(aa[k] != cc[k]){
cout << "No\n";
f = 1;
break;
}
}
if(!f)cout << "Yes\n";
}
return 0;
} int main() {
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}

7-6 非诚勿扰

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 1e9;
const int maxm = 1e5 + 5;
const int inf = 2147483647;
using namespace std; int solve(){
int n, m, k, j = 3, p = 3, f = 0, q, h;
cin >> n; k = n / 2.718; for(int i = 1; i <= n; i ++){
cin >> m; //p是找全部人中最合适的,h保留下标
if(m >= p){
p = m;
h = i;
} if(i <= k) j = max(j, m);
else if(!f && m >= j) {q = i;f = 1;}//找决定牵手的,q存下标
}
if(!f)q = 0;
cout << q << ' ' << h;
return 0;
} int main() {
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}

7-7 新式六合彩

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 1e9;
const int maxm = 1e5 + 5;
const int inf = 2147483647;
using namespace std; int a[1010][1010], minm = inf; int solve(){
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= m; j ++)
cin >> a[i][j]; int r, c, x;
cin >> r >> c >> x; for(int i = 1; i <= n; i ++){
for(int j = 1; j <= m; j ++){
if(i == r || j == c){
if(a[i][j] != -1)
//找r行或c列中差值最小的
minm = min(minm, abs(a[i][j] - x));
}
}
}
//范围小,一行一行输出就行,符合输出要求
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= m; j ++){
if(i == r || j == c){
if(a[i][j] != -1)
if((abs(a[i][j] - x)) == minm)
cout << "(" << i << ":" << j << ")" << "\n";
}
}
}
return 0;
} int main() {
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}

7-8没时间做

PTA2022 520钻石争霸赛题解的更多相关文章

  1. PTA 520钻石争霸赛 2021

    7-1 自动编程 签到题 #include<bits/stdc++.h> typedef long long ll; const int maxm = 1e5 + 5; const int ...

  2. PAT520 钻石争霸赛 7-6 随机输一次

    #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1000; ll n ...

  3. 有钱人买钻石+dfs中使用贪心

    有钱人买钻石 ECNU-3306 题解:这个题目,乍一看以为是dp背包,可是数据量却那么大,只有1,5,10,25四种面额的硬币,每种数量若干,要使得能够刚好兑换成功总金额,在此前提下,还要使得硬币数 ...

  4. AC日记——丑数 codevs 1246

    1246 丑数 USACO  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题解  查看运行结果     题目描述 Description 对于一给定的素 ...

  5. AC日记——地鼠游戏 codevs 1052

    1052 地鼠游戏  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题解       题目描述 Description 王钢是一名学习成绩优异的学生,在平 ...

  6. AC日记——最小的N个和 codevs 1245

    1245 最小的N个和  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题解  查看运行结果     题目描述 Description 有两个长度为 N ...

  7. 并查集补集作法 codevs 1069 关押罪犯

    1069 关押罪犯 2010年NOIP全国联赛提高组  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题解       题目描述 Description ...

  8. 最小生成树 kruskal算法 codevs 1638 修复公路

    1638 修复公路  时间限制: 1 s  空间限制: 256000 KB  题目等级 : 钻石 Diamond 题解       题目描述 Description A地区在地震过后,连接所有村庄的公 ...

  9. CODEVS3037 线段覆盖 5[序列DP 二分]

    3037 线段覆盖 5   时间限制: 3 s   空间限制: 256000 KB   题目等级 : 钻石 Diamond 题解       题目描述 Description 数轴上有n条线段,线段的 ...

随机推荐

  1. WPF 截图控件之绘制方框与椭圆(四) 「仿微信」

    前言 接着上周写的截图控件继续更新 绘制方框与椭圆. 1.WPF实现截屏「仿微信」 2.WPF 实现截屏控件之移动(二)「仿微信」 3.WPF 截图控件之伸缩(三) 「仿微信」 正文 有开发者在B站反 ...

  2. 7 行代码搞崩溃 B 站,原因令人唏嘘!

    前不久,哔哩哔哩(一般常称为 B 站)发布了一篇文章<2021.07.13 我们是这样崩的>,详细回顾了他们在 2021.07.13 晚上全站崩溃约 3 小时的至暗时刻,以及万分紧张的故障 ...

  3. Nginx 浏览器缓存配置指令

    # 浏览器缓存 # 当浏览器第一次访问服务器资源的时候,服务器返回到浏览器后,浏览器进行缓存 # 缓存的大概内容有: # 1.缓存过期的日期和时间 # 2.设置和缓存相关的配置信息 # 3.请求资源最 ...

  4. 【Github开源项目体验】- ZFile 基于 Java 的在线网盘

    [Github开源项目体验]- ZFile 基于 Java 的在线网盘 在线云盘.网盘.OneDrive.云存储.私有云.对象存储.h5ai.上传.下载 date: 2022-08-02 addres ...

  5. 如何基于WPF写一款数据库文档管理工具(二)

    系列目录 基于WPF重复造轮子,写一款数据库文档管理工具(一) 本篇重点 上次发表了基于WPF重复造轮子,写一款数据库文档管理工具(一) 得到不少人支持,文章一度上到了博客园推荐表首页,看来大家对这个 ...

  6. FutureTask源码深度剖析

    FutureTask源码深度剖析 前言 在前面的文章自己动手写FutureTask当中我们已经仔细分析了FutureTask给我们提供的功能,并且深入分析了我们该如何实现它的功能,并且给出了使用Ree ...

  7. 编译器优化:何为SLP矢量化

    摘要:SLP矢量化的目标是将相似的独立指令组合成向量指令,内存访问.算术运算.比较运算.PHI节点都可以使用这种技术进行矢量化. 本文分享自华为云社区<编译器优化那些事儿(1):SLP矢量化介绍 ...

  8. Qt+ECharts开发笔记(四):ECharts的饼图介绍、基础使用和Qt封装百分比图Demo

    前言   前一篇介绍了横向柱图图.本篇将介绍基础饼图使用,并将其封装一层Qt.  本篇的demo使用隐藏js代码的方式,实现了一个饼图的基本交互方式,并预留了Qt模块对外的基础接口.   Demo演示 ...

  9. Redis的两种持久化机制

    Redis的两种持久化机制 1.持久化机制 client--->redis(内存)--->内存数据-数据持久化--->磁盘 两种方法 快照(Snapshot) AOF(Append ...

  10. 解决git报错

    解决git报错:fatal: unable to access "https://github.com/.../.git/" 1.在git中执行(记得分开执行) git confi ...