結果

問題 No.1383 Numbers of Product
ユーザー kotatsugamekotatsugame
提出日時 2021-02-07 22:06:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,085 bytes
コンパイル時間 845 ms
コンパイル使用メモリ 89,372 KB
実行使用メモリ 366,676 KB
最終ジャッジ日時 2023-09-17 21:50:53
合計ジャッジ時間 15,644 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 597 ms
81,208 KB
testcase_08 AC 598 ms
80,084 KB
testcase_09 AC 737 ms
98,664 KB
testcase_10 AC 971 ms
129,372 KB
testcase_11 AC 965 ms
127,516 KB
testcase_12 AC 975 ms
129,060 KB
testcase_13 AC 935 ms
123,972 KB
testcase_14 AC 787 ms
105,056 KB
testcase_15 AC 633 ms
85,712 KB
testcase_16 AC 966 ms
127,888 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 15 ms
5,108 KB
testcase_29 AC 751 ms
101,120 KB
testcase_30 AC 990 ms
130,624 KB
testcase_31 TLE -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:41:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   41 | main()
      | ^~~~

ソースコード

diff #

#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;
}
0