题意就是一个人在走廊里一共走n次,走第i次的时候,如果i是n的因子,那么他会按下第i个灯泡。问最后第n个灯泡是不是亮着的。
求n是不是完全平方数,因为所以因子都是成对出现额度,如果是完全平方数,意味着这个数n有奇数个因子,所以n是开着的,反之是关闭的。
/*************************************************************************
> File Name: 10110.cpp
> Author: Toy
> Mail: ycsgldy@163.com
> Created Time: 2013年06月07日 星期五 21时47分23秒
************************************************************************/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <sstream>
#include <fstream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
using namespace std;
const int INF = 0x7fffffff;
typedef pair<int,int> II;
typedef vector<int> IV;
typedef vector<II> IIV;
typedef vector<bool> BV;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned int u32;
#define For(t,v,c) for(t::const_iterator v=c.begin(); v!=c.end(); ++v)
#define IsComp(n) (_c[n>>6]&(1<<((n>>1)&31)))
#define SetComp(n) _c[n>>6]|=(1<<((n>>1)&31))
const int MAXP = 46341; //sqrt(2^31)
const int SQRP = 216; //sqrt(MAX)
int _c[(MAXP>>6)+1];
IV primes;
int main ( ) {
i64 Case;
while ( scanf ( "%lld", &Case ) == 1 && Case ) {
i64 a = sqrt ( Case );
i64 tmp = a * a;
if ( tmp == Case ) printf ( "yes\n" );
else printf ( "no\n" );
}
return 0;
}