Home >WeChat Applet >Mini Program Development >Write a small program to solve an interesting perverted Mathematical Olympiad problem.

Write a small program to solve an interesting perverted Mathematical Olympiad problem.

高洛峰
高洛峰Original
2017-03-24 13:17:043477browse

The question is like this:

There are 6 people who were all born on April 11, and they are all Ox. The product of their ages in a certain year is 17597125. What is the sum of their ages in this year? ?

If you are a math whiz and have figured out a mathematical solution. Please leave your method in the comments below.

If you are a programming expert and come up with a better algorithm than the one below, please leave your method.

If you think about it, but still can’t figure it out. Then take a look at the program below.

class Gusse {
    public static void main(String[] args){
        int sut1=1,sut2=1,sut3=1,sut4=1,sut5=1,sut6=1;
        long mul=0,sum=0;
        for(sut1=1;sut1<=15;sut1++){
            for(int n2=0;n2<=10;n2++){
                sut2=sut1+n2*12;
                for(int n3=0;n3<=10;n3++){
                    sut3=sut1+n3*12;
                    for(int n4=0;n4<=10;n4++){
                        sut4=sut1+n4*12;
                        for(int n5=0;n5<=10;n5++){
                            sut5=sut1+n5*12;
                            for(int n6=0;n6<=10;n6++){
                                sut6=sut1+n6*12;
                               if((mul=sut1*sut2*sut3*sut4*sut5*sut6)==17597125){
                                   System.out.println("sut1="+sut1);
                                    System.out.println("n2="+n2);
                                    System.out.println("n3="+n3);
                                    System.out.println("n4="+n4);
                                    System.out.println("n5="+n5);
                                    System.out.println("n6="+n6);
                                    System.out.println("sum="+(sum=sut1+sut2+sut3+sut4+sut5+sut6));
                                    break;
                                }
                            }
                        }
                    }
                } 
            }
       }
       
    } 
}

Copy the program intact into Notepad, and then run it with java to get the result.

The above is the detailed content of Write a small program to solve an interesting perverted Mathematical Olympiad problem.. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn