結果

問題 No.1731 Product of Subsequence
ユーザー kotatsugamekotatsugame
提出日時 2021-11-05 21:46:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 478 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 829 ms
コンパイル使用メモリ 80,788 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 17:19:06
合計ジャッジ時間 5,881 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 391 ms
6,816 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 16 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 475 ms
6,940 KB
testcase_11 AC 407 ms
6,940 KB
testcase_12 AC 4 ms
6,940 KB
testcase_13 AC 8 ms
6,944 KB
testcase_14 AC 362 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 391 ms
6,940 KB
testcase_19 AC 9 ms
6,940 KB
testcase_20 AC 320 ms
6,940 KB
testcase_21 AC 478 ms
6,940 KB
testcase_22 AC 3 ms
6,940 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 7 ms
6,940 KB
testcase_25 AC 4 ms
6,940 KB
testcase_26 AC 69 ms
6,944 KB
testcase_27 AC 96 ms
6,940 KB
testcase_28 AC 213 ms
6,940 KB
testcase_29 AC 72 ms
6,944 KB
testcase_30 AC 367 ms
6,944 KB
testcase_31 AC 3 ms
6,944 KB
testcase_32 AC 1 ms
6,944 KB
testcase_33 AC 4 ms
6,944 KB
testcase_34 AC 24 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<map>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint1000000007;
long gcdl(long a,long b){return b?gcdl(b,a%b):a;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int N,K;
main()
{
	cin>>N>>K;
	if(K==1)
	{
		cout<<(mint(2).pow(N)-1).val()<<endl;
		return 0;
	}
	map<int,mint>mp,nxt;
	mp[K]=1;
	for(int i=0;i<N;i++)
	{
		nxt.clear();
		long _A;cin>>_A;
		int A=gcdl(_A,K);
		for(const pair<int,mint>p:mp)
		{
			int t=gcd(A,p.first);
			nxt[p.first/t]+=p.second;
			nxt[p.first]+=p.second;
		}
		mp.swap(nxt);
	}
	cout<<mp[1].val()<<endl;
}
0