結果

問題 No.1143 面積Nの三角形
ユーザー chocoruskchocorusk
提出日時 2020-08-01 00:08:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 197 ms / 800 ms
コード長 1,567 bytes
コンパイル時間 1,887 ms
コンパイル使用メモリ 139,780 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 03:51:18
合計ジャッジ時間 4,038 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 7 ms
4,380 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 11 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 77 ms
4,376 KB
testcase_12 AC 89 ms
4,376 KB
testcase_13 AC 86 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 166 ms
4,376 KB
testcase_17 AC 165 ms
4,380 KB
testcase_18 AC 197 ms
4,380 KB
testcase_19 AC 105 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
vector<pair<ll, int>> f;
ll ans;
vector<pair<pair<ll, ll>, ll>> v;
ll a[4];
void dfs(int k, ll x, ll y, ll z, ll w){
	if(k==f.size()){
		a[0]=x, a[1]=y, a[2]=z, a[3]=w;
		sort(a, a+4);
		if(a[3]==a[0]+a[1]+a[2]){
			v.push_back({{a[3]-a[2], a[3]-a[1]}, a[3]-a[0]});
		}
		return;
	}
	ll q[40]; q[0]=1;
	for(int i=0; i<f[k].second; i++) q[i+1]=q[i]*f[k].first;
	for(int i=0; i<=f[k].second; i++){
		int j1=0;
		if(k==0) j1=i;
		for(int j=j1; i+j<=f[k].second; j++){
			int l1=0;
			if(k==0) l1=j;
			for(int l=l1; i+j+l<=f[k].second; l++){
				if(k==0 && l>f[k].second-i-j-l) break;
				dfs(k+1, x*q[i], y*q[j], z*q[l], w*q[f[k].second-i-j-l]);
			}
		}
	}
}
int main()
{
	ll n; cin>>n;
	if(n==1){
		cout<<0<<endl; return 0;
	}
	ll n1=n;
	for(ll i=2; i*i<=n1; i++){
		if(n1%i==0){
			int e=0;
			while(n1%i==0){
				n1/=i; e++;
			}
			f.push_back({i, 2*e});
		}
	}
	if(n1>1) f.push_back({n1, 2});
	dfs(0, 1, 1, 1, 1);
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	cout<<v.size()<<endl;
	return 0;
}
0