HDU 6045 Is Derek lying?(思维)
来源:互联网 发布:淘宝怎么注销账号 编辑:程序博客网 时间:2024/06/03 10:09
题目地址
题意:就是告诉你有两个人去做选择题,选项有A,B,C三个,给出两个人选择的答案,然后一个人告诉大家,他们两个人的分数分别为多少,但是那个人会撒谎,判断下他是不是撒谎的
思路:就是求出A和D两个人选的相同的个数为aa,不同的为bb,然后假定A的分数是正确的,求出D的最大分数和最小分数,判断所给的D的分数是不是在这个区间里的就好了(最大和最小就是一个贪心的思想,最大的就希望对的全是A和D相同的部分,最小的就希望对的全是不同的部分)
#include <iostream>#include <cstring>#include <string>#include <queue>#include <vector>#include <map>#include <set>#include <stack>#include <cmath>#include <cstdio>#include <algorithm>#define N 80010#define LL __int64#define inf 0x3f3f3f3f#define lson l,mid,ans<<1#define rson mid+1,r,ans<<1|1using namespace std;const LL mod = 1e9 + 7;const double eps = 1e-9;int main() { cin.sync_with_stdio(false); int T; cin >> T; int mmax, mmin; int aa, bb; int n, a, b; string A, B; while (T--) { cin >> n >> a >> b; cin >> A; cin >> B; aa = 0; bb = 0; for (int i = 0; i < n; i++) { if (A[i] == B[i]) { aa++; } else { bb++; } } if (a > aa) { mmax = aa + bb - (a - aa); } else { mmax = a + bb; } if (a > bb) { mmin = a - bb; } else { mmin = 0; } if (b >= mmin&&b <= mmax) { cout << "Not lying" << endl; } else { cout << "Lying" << endl; } } return 0;}
阅读全文
0 0
- HDU 6045 Is Derek lying?(思维)
- HDU 6045 Is Derek lying?【思维】
- Is Derek lying?(HDU 6045)
- HDU 6045 Is Derek lying?(水~)
- HDU 6045 Is Derek lying?
- hdu 6045 Is Derek lying?
- HDU 6045 Is Derek lying?
- hdu--6045 Is Derek Lying
- hdu 6045 Is Derek lying?
- HDU 6045 Is Derek lying?【】
- HDU 6045 Is Derek lying?
- HDU-6045-Is Derek lying?
- hdu 6045 Is Derek lying?
- Is Derek lying? HDU
- hdu6045-思维-Is Derek lying?
- HDU 6045多校Is Derek lying?
- (数学)HDU 6045 Is Derek lying?
- HDU 6045 Is Derek lying? 水题
- YOLO2
- vue生命周期那些事儿
- 使用微软T4 template进行代码生成
- 卡特兰数
- Python爬虫学习笔记--多进程用法
- HDU 6045 Is Derek lying?(思维)
- Android高级控件之RecycleView,Gallery,ViewPage
- linux route命令详解
- Jenkins + Gerrit + Git
- Event事件对象之表单事件
- FZU 2150 Fire Game(多起点bfs)
- 调用天气api实现查询各城市天气
- UVA 11806(B)——Cheerleaders 容斥原理 离散数学列举所有情况
- Mongodb从0到1系列七: 分片