博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【topcoder SRM 702 DIV 2 250】TestTaking
阅读量:5047 次
发布时间:2019-06-12

本文共 3143 字,大约阅读时间需要 10 分钟。

Problem Statement

Recently, Alice had to take a test. The test consisted of a sequence of true/false questions. Alice was completely unprepared for the test, so she just guessed each answer.

You are given the following inputs:
an int questions: the number of questions on the test.
an int guessed: the number of questions for which Alice guessed that the answer is “true”.
an int actual: the actual number of questions for which the answer is “true”.
In the test, each correct answer was worth 1 point and each incorrect answer was worth 0 points. Compute the largest possible number of points Alice could have received.
Definition

Class:

TestTaking
Method:
findMax
Parameters:
int, int, int
Returns:
int
Method signature:
int findMax(int questions, int guessed, int actual)
(be sure your method is public)
Limits

Time limit (s):

2.000
Memory limit (MB):
256
Stack limit (MB):
256

Constraints

questions will be between 1 and 50, inclusive.

guessed, actual will be between 0 and questions, inclusive.

Examples
0)

3

1
2
Returns: 2
The test consisted of 3 statements.
Alice guessed that 1 of them is true.
Actually, there were 2 true statements on the test.
There are multiple possible outcomes of the test.
For example, it is possible that Alice wrote down the sequence of answers (false,true,false), but the correct sequence of answers is (true,false,true). In this case Alice would have received 0 points.
One possible best scenario for Alice looks as follows: Alice guessed that the answers are (false,false,true), and the correct answers are (true,false,true). In this scenario Alice would have received 0+1+1 = 2 points.
1)

3

2
1
Returns: 2

2)

5

5
0
Returns: 0
Alice guessed five times “true”, but all five correct answers were “false”. Thus, Alice certainly received 0 points.
3)

10

8
8
Returns: 10

4)

7

0
2
Returns: 5

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.

【题目链接】:

【题解】

让你猜这个人最多能得多少分.
其实答案就是min(questions-guess,question-actual)+min(guess,actual);
就是尽量让这个人的答案和结果一样。
【完整代码】

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define LL long long#define rep1(i,a,b) for (int i = a;i <= b;i++)#define rep2(i,a,b) for (int i = a;i >= b;i--)#define mp make_pair#define pb push_back#define fi first#define se secondtypedef pair
pii;typedef pair
pll;//const int MAXN = x;const int dx[5] = { 0,1,-1,0,0};const int dy[5] = { 0,0,0,-1,1};const double pi = acos(-1.0);class TestTaking{ public: int findMax(int questions, int guessed, int actual) { int a1 = min(guessed,actual); int a2 = min(questions-guessed,questions-actual); return a1+a2; }};//提交时以下部分删去.int main(){ //freopen("F:\\rush.txt","r",stdin); TestTaking A; int a,b,c; cin >> a>>b>>c; cout <

转载于:https://www.cnblogs.com/AWCXV/p/7626824.html

你可能感兴趣的文章
伪随机性
查看>>
构建高性能的ASP.NET应用(二)-性能优化演绎法
查看>>
Mysql表分区的利弊
查看>>
孙鑫MFC学习笔记12:文件读写
查看>>
使用C#开发ActiveX控件
查看>>
yum 记一次安装时的报错
查看>>
跨域(一)
查看>>
git避免提交本地配置文件-来自同事的分享
查看>>
【题解】 [ZJOI2006]书架 (Splay)
查看>>
Django ORM那些相关操作
查看>>
三星830 SSD的Smart值POR Recovery Count
查看>>
base642photo
查看>>
二分查找和数组合并
查看>>
【Java例题】5.5 两个字符串中最长公共子串
查看>>
python数据类型二
查看>>
Python-字典
查看>>
OS X下su和sudo
查看>>
乙级(Basic Level) 1011 个位数统计
查看>>
实验三+040+薛龚
查看>>
【错误】【vscode】输出中文是乱码问题
查看>>