結果

問題 No.1383 Numbers of Product
ユーザー kotatsugamekotatsugame
提出日時 2021-02-07 22:10:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,182 ms / 2,000 ms
コード長 957 bytes
コンパイル時間 827 ms
コンパイル使用メモリ 85,816 KB
実行使用メモリ 130,816 KB
最終ジャッジ日時 2024-05-02 10:21:01
合計ジャッジ時間 28,829 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 633 ms
81,280 KB
testcase_08 AC 625 ms
80,256 KB
testcase_09 AC 784 ms
98,816 KB
testcase_10 AC 1,028 ms
129,536 KB
testcase_11 AC 1,013 ms
127,616 KB
testcase_12 AC 1,043 ms
129,152 KB
testcase_13 AC 982 ms
124,160 KB
testcase_14 AC 834 ms
105,344 KB
testcase_15 AC 664 ms
85,888 KB
testcase_16 AC 1,152 ms
128,000 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 16 ms
5,376 KB
testcase_29 AC 893 ms
101,248 KB
testcase_30 AC 1,135 ms
130,816 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 278 ms
30,080 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 974 ms
119,680 KB
testcase_36 AC 925 ms
114,560 KB
testcase_37 AC 1,048 ms
130,816 KB
testcase_38 AC 1,064 ms
130,688 KB
testcase_39 AC 1,073 ms
130,688 KB
testcase_40 AC 1,041 ms
130,816 KB
testcase_41 AC 1,182 ms
130,816 KB
testcase_42 AC 1,062 ms
130,816 KB
testcase_43 AC 1,086 ms
130,816 KB
testcase_44 AC 1,077 ms
130,816 KB
testcase_45 AC 1,054 ms
130,816 KB
testcase_46 AC 1 ms
5,376 KB
testcase_47 AC 1,029 ms
128,896 KB
testcase_48 AC 1,037 ms
129,536 KB
testcase_49 AC 1,048 ms
130,560 KB
testcase_50 AC 1,061 ms
130,304 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | 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;
}
long A;
bool isok(long T)
{
	__int128 V=(__int128)K*K+4*T;
	__int128 L=0,R=1;
	while(R*R<V)R*=2;
	while(R-L>1)
	{
		__int128 mid=(L+R)/2;
		if(mid*mid<V)L=mid;
		else R=mid;
	}
	if(R*R!=V)return false;
	if((R-K)%2!=0)return false;
	__int128 a=(R-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;
		}
	}
	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