zoukankan      html  css  js  c++  java
  • Codeforces Gym 100523C C

    C - Will It Stop?
    Time Limit: 20 Sec

    Memory Limit: 256 MB

    题目连接

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87794#problem/C

    Description

    Byteasar was wandering around the library of the University of Warsaw and at one of its facades he noticed a piece of a program with an inscription “Will it stop?”. The question seemed interesting, so Byteasar tried to tackle it after returning home. Unfortunately, when he was writing down the piece of code he made a mistake and noted:
     
    while n > 1 do if n mod 2 = 0 then n := n=2 else n := 3 · n + 3
    Byteasar is now trying to figure out, for which initial values of the variable n the program he wrote down stops. We assume that the variable n has an unbounded size, i.e., it may attain arbitrarily large values.
     
     

    Input

    The first and only line of input contains one integer n (2 ¬ n ¬ 1014).

    Output

    In the first and only line of output you should write a single word TAK (i.e., yes in Polish), if the program stops for the given value of n, or NIE (no in Polish) otherwise.

    Sample Input

    4

    Sample Output

    TAK

    HINT

    题意

    给你一个数,然后问你这个数组是否会无限循环

    题解

    暴力10000000次,然后看看就吼了

    代码:

    //qscqesze
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <set>
    #include <vector>
    #include <sstream>
    #include <queue>
    #include <typeinfo>
    #include <fstream>
    #include <map>
    #include <stack>
    typedef long long ll;
    using namespace std;
    //freopen("D.in","r",stdin);
    //freopen("D.out","w",stdout);
    #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
    #define maxn 5000
    #define mod 10007
    #define eps 1e-9
    int Num;
    //const int inf=0x7fffffff;   //нчоч╢С
    const int inf=0x3f3f3f3f;
    inline ll read()
    {
        ll x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    //**************************************************************************************
    
    int main()
    {
        unsigned long long n;
        cin>>n;
        int tot=0;
        while(n>1)
        {
            if(n%2==0)
                n=n/2;
            else
                n=3*n+3;
            tot++;
            if(tot>10000000)
            {
                cout<<"NIE"<<endl;
                return 0;
            }
        }
        cout<<"TAK"<<endl;
        
    }
  • 相关阅读:
    IIS请求筛选模块被配置为拒绝超过请求内容长度的请求(转)
    解决Android AVD启动报错问题
    找新朋友
    【枚举】【SDOI 2011】【bzoj 2241】打地鼠
    Invalidate、RedrawWindow与UpdateWindow的差别
    蓝牙DA14580开发:固件格式、二次引导和烧写
    【C/C++学院】0723-32位与64位/调戏窗体程序/数据分离算法/内存检索/二分查找法/myVC
    Maven 使用 二——nexus
    Linux程序编译链接动态库版本号的问题
    Key-Value Observing (键值监測)
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4731115.html
Copyright © 2011-2022 走看看