結果

問題 No.800 四平方定理
ユーザー rookzenorookzeno
提出日時 2019-03-17 23:34:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 1,799 bytes
コンパイル時間 1,515 ms
コンパイル使用メモリ 170,380 KB
実行使用メモリ 130,844 KB
最終ジャッジ日時 2023-09-22 14:09:11
合計ジャッジ時間 5,595 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
11,488 KB
testcase_01 AC 12 ms
11,684 KB
testcase_02 AC 11 ms
11,584 KB
testcase_03 AC 11 ms
11,628 KB
testcase_04 AC 11 ms
11,500 KB
testcase_05 AC 12 ms
11,648 KB
testcase_06 AC 12 ms
11,500 KB
testcase_07 AC 12 ms
11,480 KB
testcase_08 AC 12 ms
11,616 KB
testcase_09 AC 12 ms
11,524 KB
testcase_10 AC 71 ms
70,892 KB
testcase_11 AC 83 ms
79,080 KB
testcase_12 AC 79 ms
77,024 KB
testcase_13 AC 74 ms
73,024 KB
testcase_14 AC 79 ms
79,172 KB
testcase_15 AC 79 ms
79,080 KB
testcase_16 AC 79 ms
79,072 KB
testcase_17 AC 78 ms
79,088 KB
testcase_18 AC 80 ms
79,108 KB
testcase_19 AC 79 ms
79,164 KB
testcase_20 AC 11 ms
9,748 KB
testcase_21 AC 11 ms
9,472 KB
testcase_22 AC 80 ms
79,068 KB
testcase_23 AC 159 ms
130,500 KB
testcase_24 AC 142 ms
130,648 KB
testcase_25 AC 141 ms
130,572 KB
testcase_26 AC 11 ms
9,444 KB
testcase_27 AC 11 ms
9,500 KB
testcase_28 AC 141 ms
130,588 KB
testcase_29 AC 139 ms
130,844 KB
testcase_30 AC 140 ms
130,736 KB
testcase_31 AC 131 ms
126,380 KB
testcase_32 AC 140 ms
130,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define in(s,x) s.find(x) != s.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}

// head
int m,n,k,res,tmp,tmp2,tmp3,h,w,ans;
int a[8000001] = {};
int b[8000100] = {};
int r[100001][25];
deque<PII> que;
string s;
map<int,VPII> kukan;
vector<PII> g[3000];
//int dp[200000];
int flag;
//VPII g2[200000];
int cost[200005];
ll dp[500][510] = {};
//VVI g(200005);
int d[2010][2010];

signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	cin>>n>>m;
    rep(i,1,n+1){
        rep(j,1,n+1){
            a[i*i+j*j] += 1;
            b[i*i-j*j+2000*2000] += 1;
        }
    }
    ans = 0;
    rep(i,0,2000*2000*2+1){
        if (m-i <= 2000*2000 & m-i >= -2000*2000)
        ans += a[i] * b[m-i+2000*2000];
    }
    cout<<ans<<endl;
}
0