結果

問題 No.1383 Numbers of Product
ユーザー kotatsugamekotatsugame
提出日時 2021-02-07 22:09:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,207 ms / 2,000 ms
コード長 953 bytes
コンパイル時間 723 ms
コンパイル使用メモリ 85,416 KB
実行使用メモリ 131,000 KB
最終ジャッジ日時 2023-08-14 22:15:04
合計ジャッジ時間 32,382 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 714 ms
81,396 KB
testcase_08 AC 708 ms
80,260 KB
testcase_09 AC 881 ms
98,664 KB
testcase_10 AC 1,181 ms
129,524 KB
testcase_11 AC 1,169 ms
127,512 KB
testcase_12 AC 1,193 ms
129,004 KB
testcase_13 AC 1,127 ms
124,028 KB
testcase_14 AC 952 ms
105,512 KB
testcase_15 AC 762 ms
85,796 KB
testcase_16 AC 1,175 ms
128,024 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 19 ms
5,236 KB
testcase_29 AC 904 ms
101,152 KB
testcase_30 AC 1,196 ms
130,712 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 278 ms
30,016 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1,081 ms
119,516 KB
testcase_36 AC 1,050 ms
114,668 KB
testcase_37 AC 1,191 ms
130,764 KB
testcase_38 AC 1,193 ms
130,704 KB
testcase_39 AC 1,197 ms
130,820 KB
testcase_40 AC 1,199 ms
130,732 KB
testcase_41 AC 1,205 ms
131,000 KB
testcase_42 AC 1,207 ms
130,672 KB
testcase_43 AC 1,205 ms
130,812 KB
testcase_44 AC 1,198 ms
130,816 KB
testcase_45 AC 1,206 ms
130,740 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1,179 ms
128,720 KB
testcase_48 AC 1,172 ms
129,596 KB
testcase_49 AC 1,199 ms
130,512 KB
testcase_50 AC 1,197 ms
130,392 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:37:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-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)
	{
		long 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