結果
| 問題 | 
                            No.800 四平方定理
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Bwambocos
                         | 
                    
| 提出日時 | 2019-03-17 23:15:57 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                            (最新)
                                AC
                                 
                             
                            (最初)
                            
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 740 bytes | 
| コンパイル時間 | 1,773 ms | 
| コンパイル使用メモリ | 168,508 KB | 
| 実行使用メモリ | 10,268 KB | 
| 最終ジャッジ日時 | 2024-07-08 02:23:09 | 
| 合計ジャッジ時間 | 20,956 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 22 TLE * 8 | 
ソースコード
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;
int main()
{
	LL N, D;
	in >> N >> D;
	LL ans = 0, max = N * N + D;
	LL maxx = std::min<LL>(N, sqrt(max));
	for (LL x = 1; x <= maxx; ++x)
	{
		if (x * x > max) continue;
		for (LL y = x; y <= maxx; ++y)
		{
			if (x * x + y * y > max) continue;
			for (LL z = y; z <= maxx; ++z)
			{
				if (x * x + y * y + z * z > max) continue;
				LL w2 = x * x + y * y + z * z - D;
				if (w2 > 0)
				{
					LL w = sqrt(w2);
					if (w*w == w2)
					{
						if (x == y && y == z) ans += 1;
						else if (x == y || x == z || y == z) ans += 3;
						else ans += 6;
					}
				}
			}
		}
	}
	out << ans << std::endl;
}
            
            
            
        
            
Bwambocos