You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
821 B
C++
47 lines
821 B
C++
#define _CRT_SECURE_NO_WARNINGS
|
|
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
|
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
int main()
|
|
{
|
|
int T, n;
|
|
cin >> T;
|
|
while (T--)
|
|
{
|
|
cin >> n;
|
|
while (n != 1)
|
|
{
|
|
if (n & 1)
|
|
printf("%d*3+1=%d\n", n, n * 3 + 1), n = n * 3 + 1;
|
|
else
|
|
printf("%d/2=%d\n", n, n >> 1), n >>= 1;
|
|
}
|
|
if (T) putchar('\n');
|
|
}
|
|
return 0;
|
|
}
|
|
/*
|
|
#include<iostream>
|
|
using namespace std;
|
|
int main()
|
|
{
|
|
int t;
|
|
scanf("%d",&t);
|
|
while(t--){
|
|
int n;
|
|
scanf("%d",&n);
|
|
while(n!=1){
|
|
if(n&1){
|
|
printf("%d*3+1=%d\n",n,n*3+1);
|
|
n=n*3+1;
|
|
}
|
|
else {
|
|
printf("%d/2=%d\n",n,n/2);
|
|
n=n/2;
|
|
}
|
|
}
|
|
if(t!=0)printf("\n");
|
|
}
|
|
return 0;
|
|
}
|
|
*/ |