试卷一:
① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩
0 0 1 0 1 0 0 1 0 0 得分:70
试卷二:
① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩
0 1 1 1 0 1 0 1 1 1 得分:50
试卷三:
① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩
0 1 1 1 0 0 0 1 0 1 得分:30
待批试卷:
① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩
0 0 1 1 1 0 0 1 1 1 得分:?
请编一程序依据这三张试卷,算出漏批的那张试卷的分数。
有思路么?
6 个解决方案
#1
好题目。
先看试卷一和试卷三的对比,我们发现只有7,10两个答案不同。显然如果正确的答案中不包含这两题,那么试卷二将和试卷三的分数一样都是50分。所以通过推理我们知道,第7题和第10题的答案试卷二必然是正确的。这样可知道试卷一中这两题答案均错误。现在只要找出试卷一中的一道错题就行了。我们对比试卷一和试卷三,发现他们有四道题目的答案一致。所以这四道题中一定有道错题。 否则,试卷三应该四十分。
到底哪道错了?当第一道题目错了的时候,刚好满足题目所给的分数。 所以正确答案就是
1010110101
0011100111
所以待批试卷的分数是60
先看试卷一和试卷三的对比,我们发现只有7,10两个答案不同。显然如果正确的答案中不包含这两题,那么试卷二将和试卷三的分数一样都是50分。所以通过推理我们知道,第7题和第10题的答案试卷二必然是正确的。这样可知道试卷一中这两题答案均错误。现在只要找出试卷一中的一道错题就行了。我们对比试卷一和试卷三,发现他们有四道题目的答案一致。所以这四道题中一定有道错题。 否则,试卷三应该四十分。
到底哪道错了?当第一道题目错了的时候,刚好满足题目所给的分数。 所以正确答案就是
1010110101
0011100111
所以待批试卷的分数是60
#2
不是又要穷举吧?
#3
用程序解出,待批试卷的成绩确实是60分,但仅凭上面三份试卷,得不到10题的标准答案的唯一解。
Correct Answer: 0 0 0 0 1 1 0 1 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
Correct Answer: 0 0 1 0 1 1 0 0 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
Correct Answer: 0 0 1 0 1 1 1 1 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
Correct Answer: 1 0 1 0 1 1 0 1 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
C++源代码:
---------------------
#include <iostream.h>
int Judge(unsigned correct, unsigned num);
int TestScore(unsigned correct, unsigned answer);
int CountOne(unsigned num);
char *Ltoa_B(char * buf, unsigned num, int n);
int main()
{
unsigned i=0;
unsigned answer = 0xE7;
unsigned test[3] = {0x1C5,0x1D7,0xA4};
for(i=0; i<=0x3ff; i++)
{
if(Judge(i, test[0]) != 3)
continue;
if(Judge(i, test[1]) != 5)
continue;
if(Judge(i, test[2]) != 7)
continue;
TestScore(i, answer);
}
return 0;
}
int Judge(unsigned correct, unsigned num)
{
unsigned result;
result = (correct | ~num) & (num | ~correct) & 0x3ff;
return CountOne(result);
}
int TestScore(unsigned correct, unsigned answer)
{
char buf[30];
cout<<"\nCorrect Answer: "<<Ltoa_B(buf, correct, 10)<<endl;
cout<<"Your Answer: "<<Ltoa_B(buf, answer, 10)<<endl;
cout<<"Your Score: "<<Judge(correct, answer) * 10<<endl;
return 1;
}
int CountOne(unsigned num)
{
int i=0;
unsigned j = 1;
while (j != 0)
{
if( (j & num) != 0)
i++;
j = j<<1;
}
return i;
}
char *Ltoa_B(char * buf, unsigned num, int n)
{
if (buf == NULL)
return NULL;
int i;
char *p = buf;
unsigned test=1;
test = test << (n-1);
for(i=0; i<n; i++)
{
if((test & num) == 0 )
{
*p++ = '0';
*p++ = ' ';
}
else
{
*p++ = '1';
*p++ = ' ';
}
test = test>>1;
}
p--;
*p='\0';
return buf;
}
Correct Answer: 0 0 0 0 1 1 0 1 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
Correct Answer: 0 0 1 0 1 1 0 0 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
Correct Answer: 0 0 1 0 1 1 1 1 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
Correct Answer: 1 0 1 0 1 1 0 1 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
C++源代码:
---------------------
#include <iostream.h>
int Judge(unsigned correct, unsigned num);
int TestScore(unsigned correct, unsigned answer);
int CountOne(unsigned num);
char *Ltoa_B(char * buf, unsigned num, int n);
int main()
{
unsigned i=0;
unsigned answer = 0xE7;
unsigned test[3] = {0x1C5,0x1D7,0xA4};
for(i=0; i<=0x3ff; i++)
{
if(Judge(i, test[0]) != 3)
continue;
if(Judge(i, test[1]) != 5)
continue;
if(Judge(i, test[2]) != 7)
continue;
TestScore(i, answer);
}
return 0;
}
int Judge(unsigned correct, unsigned num)
{
unsigned result;
result = (correct | ~num) & (num | ~correct) & 0x3ff;
return CountOne(result);
}
int TestScore(unsigned correct, unsigned answer)
{
char buf[30];
cout<<"\nCorrect Answer: "<<Ltoa_B(buf, correct, 10)<<endl;
cout<<"Your Answer: "<<Ltoa_B(buf, answer, 10)<<endl;
cout<<"Your Score: "<<Judge(correct, answer) * 10<<endl;
return 1;
}
int CountOne(unsigned num)
{
int i=0;
unsigned j = 1;
while (j != 0)
{
if( (j & num) != 0)
i++;
j = j<<1;
}
return i;
}
char *Ltoa_B(char * buf, unsigned num, int n)
{
if (buf == NULL)
return NULL;
int i;
char *p = buf;
unsigned test=1;
test = test << (n-1);
for(i=0; i<n; i++)
{
if((test & num) == 0 )
{
*p++ = '0';
*p++ = ' ';
}
else
{
*p++ = '1';
*p++ = ' ';
}
test = test>>1;
}
p--;
*p='\0';
return buf;
}
#4
由上述推理可看出,1、3、7、8答案不能确定
X 0 X 0 1 1 X X 1 0 (写成X)
0 0 1 1 1 0 0 1 1 1
试卷一中,这四题中错了一个
0 1 0 1
X 0 X 0 1 1 X X 1 0
于是正确答案可能是:
0 0 0 0 1 1 0 1 1 0
|
1 0 1 0 1 1 0 1 1 0
|
0 0 1 0 1 1 0 0 1 0
|
0 0 1 0 1 1 1 1 1 0
|
待批试卷的1、3、7、8,跟试卷1的一样,只有一个错,
不论如何组合不影响结果。
X 0 X 0 1 1 X X 1 0 (写成X)
0 0 1 1 1 0 0 1 1 1
试卷一中,这四题中错了一个
0 1 0 1
X 0 X 0 1 1 X X 1 0
于是正确答案可能是:
0 0 0 0 1 1 0 1 1 0
|
1 0 1 0 1 1 0 1 1 0
|
0 0 1 0 1 1 0 0 1 0
|
0 0 1 0 1 1 1 1 1 0
|
待批试卷的1、3、7、8,跟试卷1的一样,只有一个错,
不论如何组合不影响结果。
#5
怎么搞得那么复杂?
用穷举法也才2的10次方,1024次而已,对于计算机是很短的时间。
用穷举法也才2的10次方,1024次而已,对于计算机是很短的时间。
#6
一点都不复杂啊,推理一下很快就能出结果。
写个穷举的程序还要花些时间。
写个穷举的程序还要花些时间。
#1
好题目。
先看试卷一和试卷三的对比,我们发现只有7,10两个答案不同。显然如果正确的答案中不包含这两题,那么试卷二将和试卷三的分数一样都是50分。所以通过推理我们知道,第7题和第10题的答案试卷二必然是正确的。这样可知道试卷一中这两题答案均错误。现在只要找出试卷一中的一道错题就行了。我们对比试卷一和试卷三,发现他们有四道题目的答案一致。所以这四道题中一定有道错题。 否则,试卷三应该四十分。
到底哪道错了?当第一道题目错了的时候,刚好满足题目所给的分数。 所以正确答案就是
1010110101
0011100111
所以待批试卷的分数是60
先看试卷一和试卷三的对比,我们发现只有7,10两个答案不同。显然如果正确的答案中不包含这两题,那么试卷二将和试卷三的分数一样都是50分。所以通过推理我们知道,第7题和第10题的答案试卷二必然是正确的。这样可知道试卷一中这两题答案均错误。现在只要找出试卷一中的一道错题就行了。我们对比试卷一和试卷三,发现他们有四道题目的答案一致。所以这四道题中一定有道错题。 否则,试卷三应该四十分。
到底哪道错了?当第一道题目错了的时候,刚好满足题目所给的分数。 所以正确答案就是
1010110101
0011100111
所以待批试卷的分数是60
#2
不是又要穷举吧?
#3
用程序解出,待批试卷的成绩确实是60分,但仅凭上面三份试卷,得不到10题的标准答案的唯一解。
Correct Answer: 0 0 0 0 1 1 0 1 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
Correct Answer: 0 0 1 0 1 1 0 0 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
Correct Answer: 0 0 1 0 1 1 1 1 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
Correct Answer: 1 0 1 0 1 1 0 1 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
C++源代码:
---------------------
#include <iostream.h>
int Judge(unsigned correct, unsigned num);
int TestScore(unsigned correct, unsigned answer);
int CountOne(unsigned num);
char *Ltoa_B(char * buf, unsigned num, int n);
int main()
{
unsigned i=0;
unsigned answer = 0xE7;
unsigned test[3] = {0x1C5,0x1D7,0xA4};
for(i=0; i<=0x3ff; i++)
{
if(Judge(i, test[0]) != 3)
continue;
if(Judge(i, test[1]) != 5)
continue;
if(Judge(i, test[2]) != 7)
continue;
TestScore(i, answer);
}
return 0;
}
int Judge(unsigned correct, unsigned num)
{
unsigned result;
result = (correct | ~num) & (num | ~correct) & 0x3ff;
return CountOne(result);
}
int TestScore(unsigned correct, unsigned answer)
{
char buf[30];
cout<<"\nCorrect Answer: "<<Ltoa_B(buf, correct, 10)<<endl;
cout<<"Your Answer: "<<Ltoa_B(buf, answer, 10)<<endl;
cout<<"Your Score: "<<Judge(correct, answer) * 10<<endl;
return 1;
}
int CountOne(unsigned num)
{
int i=0;
unsigned j = 1;
while (j != 0)
{
if( (j & num) != 0)
i++;
j = j<<1;
}
return i;
}
char *Ltoa_B(char * buf, unsigned num, int n)
{
if (buf == NULL)
return NULL;
int i;
char *p = buf;
unsigned test=1;
test = test << (n-1);
for(i=0; i<n; i++)
{
if((test & num) == 0 )
{
*p++ = '0';
*p++ = ' ';
}
else
{
*p++ = '1';
*p++ = ' ';
}
test = test>>1;
}
p--;
*p='\0';
return buf;
}
Correct Answer: 0 0 0 0 1 1 0 1 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
Correct Answer: 0 0 1 0 1 1 0 0 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
Correct Answer: 0 0 1 0 1 1 1 1 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
Correct Answer: 1 0 1 0 1 1 0 1 1 0
Your Answer: 0 0 1 1 1 0 0 1 1 1
Your Score: 60
C++源代码:
---------------------
#include <iostream.h>
int Judge(unsigned correct, unsigned num);
int TestScore(unsigned correct, unsigned answer);
int CountOne(unsigned num);
char *Ltoa_B(char * buf, unsigned num, int n);
int main()
{
unsigned i=0;
unsigned answer = 0xE7;
unsigned test[3] = {0x1C5,0x1D7,0xA4};
for(i=0; i<=0x3ff; i++)
{
if(Judge(i, test[0]) != 3)
continue;
if(Judge(i, test[1]) != 5)
continue;
if(Judge(i, test[2]) != 7)
continue;
TestScore(i, answer);
}
return 0;
}
int Judge(unsigned correct, unsigned num)
{
unsigned result;
result = (correct | ~num) & (num | ~correct) & 0x3ff;
return CountOne(result);
}
int TestScore(unsigned correct, unsigned answer)
{
char buf[30];
cout<<"\nCorrect Answer: "<<Ltoa_B(buf, correct, 10)<<endl;
cout<<"Your Answer: "<<Ltoa_B(buf, answer, 10)<<endl;
cout<<"Your Score: "<<Judge(correct, answer) * 10<<endl;
return 1;
}
int CountOne(unsigned num)
{
int i=0;
unsigned j = 1;
while (j != 0)
{
if( (j & num) != 0)
i++;
j = j<<1;
}
return i;
}
char *Ltoa_B(char * buf, unsigned num, int n)
{
if (buf == NULL)
return NULL;
int i;
char *p = buf;
unsigned test=1;
test = test << (n-1);
for(i=0; i<n; i++)
{
if((test & num) == 0 )
{
*p++ = '0';
*p++ = ' ';
}
else
{
*p++ = '1';
*p++ = ' ';
}
test = test>>1;
}
p--;
*p='\0';
return buf;
}
#4
由上述推理可看出,1、3、7、8答案不能确定
X 0 X 0 1 1 X X 1 0 (写成X)
0 0 1 1 1 0 0 1 1 1
试卷一中,这四题中错了一个
0 1 0 1
X 0 X 0 1 1 X X 1 0
于是正确答案可能是:
0 0 0 0 1 1 0 1 1 0
|
1 0 1 0 1 1 0 1 1 0
|
0 0 1 0 1 1 0 0 1 0
|
0 0 1 0 1 1 1 1 1 0
|
待批试卷的1、3、7、8,跟试卷1的一样,只有一个错,
不论如何组合不影响结果。
X 0 X 0 1 1 X X 1 0 (写成X)
0 0 1 1 1 0 0 1 1 1
试卷一中,这四题中错了一个
0 1 0 1
X 0 X 0 1 1 X X 1 0
于是正确答案可能是:
0 0 0 0 1 1 0 1 1 0
|
1 0 1 0 1 1 0 1 1 0
|
0 0 1 0 1 1 0 0 1 0
|
0 0 1 0 1 1 1 1 1 0
|
待批试卷的1、3、7、8,跟试卷1的一样,只有一个错,
不论如何组合不影响结果。
#5
怎么搞得那么复杂?
用穷举法也才2的10次方,1024次而已,对于计算机是很短的时间。
用穷举法也才2的10次方,1024次而已,对于计算机是很短的时间。
#6
一点都不复杂啊,推理一下很快就能出结果。
写个穷举的程序还要花些时间。
写个穷举的程序还要花些时间。