PTA2022 520钻石争霸赛题解
2024-10-12 09:43:37
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没时间做
最新文章
- 转: IntelliJ IDEA 2016.2.2注册码
- java-冒泡排序
- Android 屏幕滑动事件
- cmake用法(转)
- 代码中特殊的注释技术&mdash;&mdash;TODO、FIXME和XXX的用处
- 简单JS实现对表的行的增删
- hdu 4739 Zhuge Liang&#39;s Mines 随机化
- MS MQ 消息队列
- 比较X与Y的大小,绝对精准!!!!!!
- Azure PowerShell (一)如何安装和配置 Azure PowerShell
- 【HDOJ】2149 Public Sale
- VS2010/MFC对话框:文件对话框
- Codeforces Round #198 (Div. 2) C. Tourist Problem
- ajax请求处理和views处理函数的优先级
- 微信【跳一跳】 opencv视觉识别 + 物理外挂
- python2和python3的内存使用情况
- include 指令和 include 动作引入 jsp 页面时中文乱码
- 题解 P2920 【[USACO08NOV]时间管理Time Management】
- AndroidStudio自定义TODO
- json-rpc和restful
热门文章
- 表单中设置了 `keyup.enter.native` 的按键事件,但是回车后没有执行查询,反而会刷新页面
- Maven 聚合工程
- 基于Anacoda搭建虚拟环境cudnn6.0+cuda8.0+python3.6+tensorflow-gpu1.4.0
- shellcode 注入执行技术学习
- Windows 系统 PostgreSQL 手工安装配置方法
- JAVA反序列化漏洞修复解决方法
- KingbaseES 的闪回查询
- centOS查看修改时区
- 【Java面试】这应该是面试官最想听到的回答,Mysql如何解决幻读问题?
- Centos7下安装postgresql(tar包形式安装)