結果

問題 No.736 約比
ユーザー aguroshouaguroshou
提出日時 2018-09-28 22:20:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 859 ms / 2,000 ms
コード長 2,837 bytes
コンパイル時間 823 ms
コンパイル使用メモリ 83,268 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 11:08:12
合計ジャッジ時間 3,502 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 202 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 15 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 859 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 5 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 1 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 5 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 1 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 114 ms
5,376 KB
testcase_47 AC 1 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 9 ms
5,376 KB
testcase_50 AC 1 ms
5,376 KB
testcase_51 AC 1 ms
5,376 KB
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 1 ms
5,376 KB
testcase_55 AC 1 ms
5,376 KB
testcase_56 AC 1 ms
5,376 KB
testcase_57 AC 1 ms
5,376 KB
testcase_58 AC 3 ms
5,376 KB
testcase_59 AC 2 ms
5,376 KB
testcase_60 AC 3 ms
5,376 KB
testcase_61 AC 1 ms
5,376 KB
testcase_62 AC 1 ms
5,376 KB
testcase_63 AC 2 ms
5,376 KB
testcase_64 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;
int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0;
	ll n, m, h, w, X;
	ll k;
	ll insuusyurui[1000] = {};
	ll insuukazu[1000] = {};
	ll memo[4000] = {};
	ll memo2[4000] = {};
	cin >> n;
	ll z[103] = {};
	ll A[103] = {};
	ll B[103] = {};
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
		B[i] = A[i];
	}
	ll N = A[0];
	a = 2;
	// √n ≧ a ( n ≧ a * a ) の間ループ処理
	while (N >= a * a) {
		// a で割り切れたら、a は素因数
		// そして、割られる数を a で割る
		// a で割り切れなかったら、 a を 1 増加させる
		if (N % a == 0) {
			//printf("%d * ", a);
			z[c] = a;
			N /= a;
			c++;
		}
		else
		{
			a++;
			//if (insuukazu[c] != 0)
			{
				//	c++;
					//cout << c << endl;

			}
		}
	}
	//printf("%d\n", N);
	z[c] = N;
	for (int i = 0; i < c + 10; i++)
	{
		//cout << z[i] << endl;
	}
	for (int i = 0; i < n; i++)
	{
		for (int k = 0; k <= c; k++)
		{
			if (z[k] != 0)
			{
				if (A[i] % z[k] == 0)
				{
					A[i] /= z[k];
				}
				else
				{
					z[k] = 0;
				}
			}
		}
	}
	d = 1;
	for (int i = 0; i <= c; i++)
	{
		if (z[i] != 0)
		{
			d *= z[i];
		}
	}

	for (int i = 0; i < c + 10; i++)
	{
		//cout << z[i] << endl;
	}
	for (int i = 0; i < n; i++)
	{
		//cout << A[i] / d << endl;
		cout << B[i] / d;
		if (i<n-1)
		{
		cout << ":";

		}

	}
	cout  << endl;

	//cout << sum << endl;
	//cout <<  endl;

	return 0;
}

//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}




//
//ll insuusyurui[1000] = {};
//ll insuukazu[1000] = {};
//ll memo[4000] = {};
//ll memo2[4000] = {};
//cin >> n;
//cin >> m;
//a = 2;
//// √n ≧ a ( n ≧ a * a ) の間ループ処理
//while (n >= a * a) {
//	// a で割り切れたら、a は素因数
//	// そして、割られる数を a で割る
//	// a で割り切れなかったら、 a を 1 増加させる
//	if (n % a == 0) {
//		printf("%d * ", a);
//		insuukazu[c]++;
//		n /= a;
//	}
//	else {
//		a++;
//		//if (insuukazu[c] != 0)
//		{
//			c++;
//			//cout << c << endl;
//
//		}
//	}
//}
//printf("%d\n", n);
//for (int i = 0; i < c; i++)
//{
//	//cout << insuukazu[i] << endl;
//}
//
//cout << "Yes" << endl;
0