Submission #117021


Source Code Expand

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define REV(s) (s).rbegin(), (s).rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

bool np[10010];
vector<int> p;

int main(){
	for(int i = 2; i < 10010; i++){
		if(!np[i]){
			for(int j = i*2; j < 10010; j+= 2){
				np[j] = 1;
			}
			p.push_back(i);
		}
	}

	int n;
	while(cin >> n, n){
		int x = 0;
		rep(i, p.size()){
			while(n%p[i] == 0){
				n/=p[i];
				x = max(x, p[i]);
			}
		}
		if(n != 1) cout << n << endl;
		else cout << x << endl;
	}
	
	return 0;
}

Submission Info

Submission Time
Task B - Working for the World
User yuusti
Language C++ (G++ 4.6.4)
Score 100
Code Size 1057 Byte
Status AC
Exec Time 32 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 30 ms 804 KB
10-minimum AC 30 ms 928 KB
11-maximum AC 31 ms 916 KB
12-little AC 30 ms 800 KB
13-large AC 30 ms 800 KB
14-middle AC 31 ms 932 KB
15-zero AC 30 ms 804 KB
50-random00 AC 30 ms 804 KB
50-random01 AC 30 ms 800 KB
50-random02 AC 29 ms 920 KB
50-random03 AC 31 ms 924 KB
50-random04 AC 32 ms 796 KB
50-random05 AC 31 ms 932 KB
50-random06 AC 30 ms 864 KB
50-random07 AC 30 ms 924 KB
50-random08 AC 30 ms 864 KB
50-random09 AC 30 ms 804 KB
50-random10 AC 30 ms 932 KB
50-random11 AC 30 ms 796 KB
50-random12 AC 30 ms 796 KB
50-random13 AC 30 ms 756 KB
50-random14 AC 30 ms 796 KB
50-random15 AC 29 ms 800 KB
50-random16 AC 31 ms 928 KB
50-random17 AC 31 ms 924 KB
50-random18 AC 31 ms 864 KB
50-random19 AC 31 ms 860 KB