結果

問題 No.375 立方体のN等分 (1)
ユーザー Yut176Yut176
提出日時 2016-06-04 23:55:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 887 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 70,816 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-04-17 01:54:19
合計ジャッジ時間 7,137 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	long long int n;
	cin >> n;
	long long int s=0,l=0;
	vector<int> v;
	v.push_back(1);
	v.push_back(1);
	l=n-1;
	while(true){
		for(int i=2;i<=n;i++){
			if(n%i == 0){
				n = n/i;
				v.push_back(i);
				break;

			}
		}
		if(n==1 ) break;
	}

	// for(int i=0;i<v.size();i++){
	// 	cout << v[i] << endl;
	// }

	while(v.size() > 3){
		sort(v.begin(),v.end());
		v[1] = v[0]*v[1];
		// cout <<v[0]<<" "<<v[1]<<" "<<v[2]<<endl;
		v[0] = 0;
		// vector<int>::iterator end_it = remove( v.begin(), v.begin()+1, 0 );
		// remove(v.begin(),v.begin()+1,0);
		v.erase(remove(v.begin(), v.end(), 0), v.end());
	}
	// cout <<"  kkk"<<endl;

	// for(int i=0;i<v.size();i++){
	// 	cout << v[i] << endl;
	// }
	s = v[0] + v[1] + v[2] -3;


	cout << s <<" "<< l<<endl;


}
0