結果

問題 No.2177 Recurring ab
ユーザー ace_amuroace_amuro
提出日時 2023-03-29 17:53:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,123 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 82,608 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 08:41:55
合計ジャッジ時間 2,121 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<ctime>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
typedef long long LL;
const int MR=1e6+10;
LL n,ans;
LL sq(LL x){
    LL l=0,r=2e9;
    while(l+1<r){
        LL m=(l+r)/2;
        if(m*m<=x) l=m;
        else r=m;
    }
    return l;
}
int main(){
    cin>>n;
    for(LL p=2;p<10;p++){
        for(LL a=0;a<p;a++){
            for(LL b=0;b<p;b++){
                if(a==b) continue;
                if(a*p*n+b*n>p*p-1) ans++;
            }
        }
    }
    for(LL a=0;a<10;a++){
        for(LL b=0;b<10;b++){
            if(a==b) continue;
            LL D=n*n*a*a+4*n*b+4;
            LL rd=sq(D);
            LL tmp=n*a+rd;
            //printf("a=%lld b=%lld D=%lld rd=%lld tmp=%lld\n",a,b,D,rd,tmp);
            if(tmp%2){
                ans+=max(0ll,tmp/2-9);
            }
            else{
                if(rd*rd==D) ans+=max(0ll,tmp/2-10);
                else ans+=max(0ll,tmp/2-9);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}
0