結果
| 問題 | No.1318 ABCD quadruplets |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-02-11 02:35:41 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,987 bytes |
| 記録 | |
| コンパイル時間 | 3,184 ms |
| コンパイル使用メモリ | 334,272 KB |
| 実行使用メモリ | 16,320 KB |
| 最終ジャッジ日時 | 2026-02-11 02:35:49 |
| 合計ジャッジ時間 | 7,709 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 TLE * 1 -- * 19 |
ソースコード
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define double long double
#define float double
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define nl '\n'
#define here cout << "HERE" << endl;
#define forn(i, a, n) for (int i = a; i < n; i++)
#define print(a) for (auto& e : a) cout << e << " "; cout << endl;
#define MOD(a, b) (((a) % (b) + (b)) % (b))
#define yesno(b) cout << ((b) ? "YES\n" : "NO\n")
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using vi = vector<int>;
using pii = pair<int,int>;
// a^2 + b^2 + c^2 + d^2
// + ab + ac + ad + bc + bd + cd
// take common ?
// a(a+b+c+d)+b(b+c+d)+c(c+d)+d=n
// f(0,m) just set one to 0
// whole square ?
// (a+b+c+d)^2= (a+b+c+d)(a+b+c+d)
// (a+b+c+d)^2= a(a+b+c+d) + b(a+b+c+d) +c(a+b+c+d) + d(a+b+c+d)
// (a+b+c+d)^2= a^2+ab+ac+ad + ab+b^2+bc+bd + ac+ab+c^2+cd + ad+ab+cd+d^2
// (a+b+c+d)^2= a^2 + b^2 + c^2 + d^2 + 2(ab + ac + ad + bc + bd + cd)
// (a+b+c+d)^2/2 =n
// (a+b+c+d)^2=2*n
// 0 to m loop for every n ?
// that's m*n = 160000*sqrt(160000)
// m*n=64000000
void solve(){
int n,m;
cin>>n>>m;
for(int i=0;i<=n;i++){
int out=0;
for(int a=0;a<=m;a++){
if(a*a>n)continue;
for(int b=0;b<=m;b++){
if(b*b>n || a*b>n)continue;
for(int c=0;c<=m;c++){
if(c*c>n || a*c>n || b*c>n)continue;
for(int d=0;d<=m;d++){
int jba=(a*a)+(b*b)+(c*c)+(d*d)+(a*b)+(a*c)+(a*d)+(b*c)+(b*d)+(c*d);
if(jba==i)out++;
}
}
}
}
cout<<out<<nl;
}
// cout<<nl;
}
signed main(){
fast
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int t = 1;
// cin >> t;
for(int i=0;i<t;i++){
// cout<<"Case "<<i+1<<": ";
solve();
}
return 0;
}
vjudge1