結果
問題 |
No.1383 Numbers of Product
|
ユーザー |
|
提出日時 | 2021-02-07 22:06:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,085 bytes |
コンパイル時間 | 874 ms |
コンパイル使用メモリ | 91,184 KB |
実行使用メモリ | 371,872 KB |
最終ジャッジ日時 | 2024-07-04 15:39:30 |
合計ジャッジ時間 | 14,052 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 TLE * 1 -- * 21 |
コンパイルメッセージ
main.cpp:41:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 41 | main() | ^~~~
ソースコード
#include<iostream> #include<cmath> #include<map> #include<vector> #include<set> using namespace std; long N,K,M; map<long,long>cnt; long count2() { long L=0,R=1e9; while(R-L>1) { long mid=(L+R)/2; if(mid+K>N/mid)R=mid; else L=mid; } return L; } set<long>issq; long A; bool isok(long T) { if(K>(int)1e8) { return issq.find(T)!=issq.end(); } long V=K*K+4*T; long L=0,R=25e8; while(R-L>1) { long mid=(L+R)/2; if(mid*mid<=V)L=mid; else R=mid; } if(L*L!=V)return false; if((L-K)%2!=0)return false; long a=(L-K)/2; return a>=A; } main() { cin>>N>>K>>M; A=1; for(;;A++) { if(A+K>N/A)break; long T=A; long U=A+K; int tm=0; while(U<=N/T) { T*=U; U+=K; cnt[T]++; tm++; } if(tm==1) { cnt[T]--; if(cnt[T]==0)cnt.erase(T); break; } } if(K>(int)1e8) { for(long a=A;;a++) { if(a+K>N/a)break; issq.insert(a*(a+K)); } } long one=count2()-A+1; long ans=0; for(pair<long,long>p:cnt) { int now=p.second; if(isok(p.first)) { one--; now++; } if(now==M)ans++; } cout<<ans+(M==1?one:0)<<endl; }