結果
問題 | No.2177 Recurring ab |
ユーザー |
|
提出日時 | 2023-03-29 17:53:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,123 bytes |
コンパイル時間 | 715 ms |
コンパイル使用メモリ | 82,496 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-21 09:45:46 |
合計ジャッジ時間 | 1,681 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#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; }