Hangzhou Electric HDU 1279 Verifying the Angle Valley conjecture

Source: Internet
Author: User

Verifying the Angle Valley conjecture Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 6653 Accepted Submission (s): 3417


There are many speculations in problem description number theory that have not yet been resolved, one of which is known as the "Angular Valley conjecture", a problem that was popular in several prestigious universities in cert, the problem is described as: any one greater than the natural number, if it is odd, is multiplied by three plus one, and if an even number is divided by two, the resulting result continues to be computed according to the preceding rule, and one must finally be obtained. Now ask you to write a program to verify his correctness.
Input has multiple test data sets, the first behavior tests the number of data groups N, followed by the N-line positive integers.

The output outputs verify the odd number in the "Angle Valley conjecture" process, and the last 1 do not output; one row per test problem, only two outputs in each row can have a space, if there is no such output, then the output: No number can be output!.

Sample Input
4591611

Sample Output
7 5No number can be output!11 17 13 5
Water, water, water and water tonight ~ ~
#include <iostream>using namespace Std;int main () {int N;while (cin>>n) {int x;for (int m=0;m<n;m++) {cin >>x;int flag=0;int Ls[1000],t=0;while (x!=1) {if ((x&1)) {       flag=1;       ls[t++]=x;}     if (x%2==0) {   x/=2;}       else    {  flag=1;  x=x*3+1;}   } if (!flag) cout<< "No number can be output!" <<endl;else{int v;for (v=0;v<t-1;v++) cout<<ls[v]<< ""; Cout<<ls[v]<<endl;}} return 0;}

Hangzhou Electric HDU 1279 Verifying the Angle Valley conjecture

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.