結果

問題 No.36 素数が嫌い!
ユーザー koba-e964koba-e964
提出日時 2015-05-13 13:31:54
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 101 ms / 5,000 ms
コード長 1,912 bytes
コンパイル時間 1,267 ms
コンパイル使用メモリ 91,420 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 07:09:49
合計ジャッジ時間 2,261 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 34 ms
4,380 KB
testcase_12 AC 101 ms
4,376 KB
testcase_13 AC 101 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 6 ms
4,380 KB
testcase_20 AC 5 ms
4,376 KB
testcase_21 AC 14 ms
4,376 KB
testcase_22 AC 3 ms
4,384 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 16 ms
4,380 KB
testcase_25 AC 19 ms
4,376 KB
testcase_26 AC 36 ms
4,380 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 36 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;

class Power {
	typedef long long i64;
public:
	/* a^b with no modulo operations */
	static long long power(long long a, long long b) {
		i64 s = 1;
		i64 c = a;
		while (b > 0) {
			if (b % 2) {
				s *= c;
			}
			c *= c;
			b /= 2;
		}
		return s;
	}
	/* return (a,b) s.t, n = a^b and b is maximal. O(64) */
	static pair<long long, int> toPower(long long n) {
		for (int i = 64; i >= 2; i--) {
			i64 app = pow(n, 1.0/i);
			for (int d = -4; d <= 4; d++) {
				i64 x = app + d;
				if (x <= 0) continue;
				if (power(x, i) == n) {
					return pair<i64, int>(x, i);
				}
			}
		}
		return pair<i64, int>(n, 1);
	}
	/* factorize n and returns prime factors and their exponents.  O(sqrt(n)) */
	static vector<pair<long long, int> > factorize(long long n) {
		vector<pair<i64, int> > res;
		i64 p = 2;
		int c = 0;
		while (n >= 1) {
			if (c == 0 && n < p * p) {
			  if(n != 1) {
			    res.push_back(pair<i64, int>(n,1));
			  }
			  break;
			}
			if (n % p != 0) {
				if (c > 0) {
					res.push_back(pair<i64, int>(p,c));
				}
				p++;
				c = 0;
				continue;
			}
			n /= p;
			c++;
		}
		return res;
	}
};

int main(void){
  ll n;
  cin >> n;
  vector<pair<ll, int> > res = Power::factorize(n);
  int t = 0;
  REP(i, 0, res.size()) {
    t += res[i].second;
  }
  cout << (t >= 3 ? "YES" : "NO") << endl;
}
0