Algorithm to improve the time limit: 1.0s memory limit: 256.0MB altogether has 5 red scarf, the number is a, B, C, D, E, the old woman was one of them helped across the road.
Five red scarves each speak:
A: Neither I nor E have helped the old lady.
B: Granny was helped by one of the C and E.
C: The granny was one of me and D who helped the street.
D:b and C didn't help Granny cross the street.
E: I didn't help Granny.
Known five red scarf and only 2 people are telling the truth, please ask who helped this granny over the street.
If there are multiple answers, the output is in one line and the number is separated by a space.
For example
A B C D E (This is obviously not the correct answer)
public class Main {
static int a[]=new int[5];
public static void Main (string[] args) {
int sum;
for (int i=0; i<5; i++)
{
sum=0;//records the number of truths
a[i]=1;//The assumption that the first person to help , to help the note is 1, did not help 0
if (a[0]==0& &a[4]==0)//a said , if a does not help and E did not help, is the truth
sum++; Then sum++
if (a[2]!=0| | a[4]!=0)//b said
sum++;
if (a[2]!=0| | a[3]!=0)//c
sum++;
if (a[1]==0&&a[2]==0)//d
sum++;
if (a[4]==0)//e
sum++;
if (sum==2)//Exactly two people say the truth
{System.out.print ((char) (' A ' +i) + ");}
a[i]=0;//at the end of each loop 0}}}