結果

問題 No.1143 面積Nの三角形
ユーザー 👑 kmjpkmjp
提出日時 2020-07-31 23:29:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 800 ms
コード長 1,423 bytes
コンパイル時間 2,277 ms
コンパイル使用メモリ 207,552 KB
実行使用メモリ 51,024 KB
最終ジャッジ日時 2023-09-21 03:02:37
合計ジャッジ時間 3,921 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
50,688 KB
testcase_01 AC 19 ms
50,728 KB
testcase_02 AC 19 ms
50,684 KB
testcase_03 AC 20 ms
50,792 KB
testcase_04 AC 19 ms
50,660 KB
testcase_05 AC 20 ms
50,708 KB
testcase_06 AC 20 ms
50,796 KB
testcase_07 AC 23 ms
50,704 KB
testcase_08 AC 27 ms
50,748 KB
testcase_09 AC 29 ms
50,712 KB
testcase_10 AC 28 ms
50,748 KB
testcase_11 AC 36 ms
50,744 KB
testcase_12 AC 40 ms
50,824 KB
testcase_13 AC 41 ms
50,932 KB
testcase_14 AC 31 ms
50,644 KB
testcase_15 AC 21 ms
50,752 KB
testcase_16 AC 55 ms
50,952 KB
testcase_17 AC 56 ms
51,024 KB
testcase_18 AC 52 ms
50,728 KB
testcase_19 AC 50 ms
50,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


//A051584

ll N;

set<int> H[1010100];

ll issq(ll V) {
	ll a=sqrt(V);
	if(a*a==V) return a;
	if((a-1)*(a-1)==V) return a-1;
	if((a+1)*(a+1)==V) return a+1;
	return -1;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	ll M=N*N;
	vector<ll> A;
	for(i=1;1LL*i*i<=M;i++) if(M%i==0) {
		A.push_back(i);
		if(1LL*i*i!=M) A.push_back(M/i);
	}
	
	sort(ALL(A));
	
	int num=0;
	FOR(x,A.size()) {
		if(A[x]>N) break;
		for(y=x;y<A.size();y++) {
			if(A[y]>N) break;
			if(M%(A[x]*A[y])) continue;
			ll c=-M/(A[x]*A[y]);
			ll b=A[x]+A[y];
			ll d=b*b-4*c;
			if(d<0) continue;
			ll v=issq(d);
			if(v<0) continue;
			v-=b;
			if(v<0) continue;
			if(v%2) continue;
			if(A[y]<=v/2 && v/2<N) num++;
			
			
			
		}
	}
	
	
	
	
	cout<<num<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0