【练习01】 简单题(1)1012

来源:互联网 发布:电脑软件删不掉怎么办 编辑:程序博客网 时间:2024/06/05 11:42

Switch Game

像这种题一般的蛮力法是会超时的,只能通过打印一部分结果然后找规律再确定怎么写程序。

#include<iostream>#include<cmath>using namespace std;int main(){    int m;    while(cin>>m){        int temp = (int)sqrt(double(m));        temp *= temp;        if(temp == m){            cout<<1<<endl;        }else{            cout<<0<<endl;        }    }    system("pause");}