现在的位置: 首页 > 综合 > 正文

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

2013年10月13日 ⁄ 综合 ⁄ 共 316字 ⁄ 字号 评论关闭

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");
}

抱歉!评论已关闭.