Submission #117099


Source Code Expand

#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <list>
#include <cassert>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define EPS 1e-9
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

const int COMPUTEPRIMEFACTORS_MAXN = 10001;
int primeFactors[COMPUTEPRIMEFACTORS_MAXN+1];
void computePrimeFactors() {
	primeFactors[1] = 1;
	rer(i, 2, COMPUTEPRIMEFACTORS_MAXN) if(!primeFactors[i]) {
		primeFactors[i] = i;
		if((ll)i * i <= COMPUTEPRIMEFACTORS_MAXN)
		for(int j = i * i; j <= COMPUTEPRIMEFACTORS_MAXN; j += i) {
			if(!primeFactors[j]) primeFactors[j] = i;
		}
	}
}

int main() {
	computePrimeFactors();
	int n;
	while(cin >> n, n) {
		int r = 0, x = n;
		for(int i = 2; i * i <= n; i ++)
			if(primeFactors[i] == i && n % i == 0) {
				r = max(r, i);
				while(x % i == 0) x /= i;
			}
		if(x != 1) r = max(r, x);
		cout << r << endl;
	}
	return 0;
}

Submission Info

Submission Time
Task B - Working for the World
User anta
Language C++ (G++ 4.6.4)
Score 100
Code Size 1935 Byte
Status AC
Exec Time 23 ms
Memory 932 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 27
Set Name Test Cases
All 00-sample, 10-minimum, 11-maximum, 12-little, 13-large, 14-middle, 15-zero, 50-random00, 50-random01, 50-random02, 50-random03, 50-random04, 50-random05, 50-random06, 50-random07, 50-random08, 50-random09, 50-random10, 50-random11, 50-random12, 50-random13, 50-random14, 50-random15, 50-random16, 50-random17, 50-random18, 50-random19
Case Name Status Exec Time Memory
00-sample AC 22 ms 800 KB
10-minimum AC 22 ms 928 KB
11-maximum AC 21 ms 760 KB
12-little AC 21 ms 928 KB
13-large AC 22 ms 924 KB
14-middle AC 21 ms 808 KB
15-zero AC 21 ms 928 KB
50-random00 AC 21 ms 800 KB
50-random01 AC 21 ms 928 KB
50-random02 AC 21 ms 808 KB
50-random03 AC 22 ms 800 KB
50-random04 AC 21 ms 928 KB
50-random05 AC 22 ms 924 KB
50-random06 AC 20 ms 924 KB
50-random07 AC 22 ms 928 KB
50-random08 AC 22 ms 756 KB
50-random09 AC 22 ms 800 KB
50-random10 AC 22 ms 932 KB
50-random11 AC 22 ms 804 KB
50-random12 AC 22 ms 924 KB
50-random13 AC 21 ms 804 KB
50-random14 AC 20 ms 920 KB
50-random15 AC 22 ms 928 KB
50-random16 AC 22 ms 804 KB
50-random17 AC 21 ms 928 KB
50-random18 AC 23 ms 932 KB
50-random19 AC 22 ms 920 KB