結果

問題 No.1731 Product of Subsequence
ユーザー kotatsugamekotatsugame
提出日時 2021-11-05 21:46:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 517 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 818 ms
コンパイル使用メモリ 83,040 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-07 23:02:48
合計ジャッジ時間 6,509 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 420 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 17 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 513 ms
4,380 KB
testcase_11 AC 439 ms
4,376 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 9 ms
4,380 KB
testcase_14 AC 383 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 413 ms
4,380 KB
testcase_19 AC 10 ms
4,376 KB
testcase_20 AC 335 ms
4,376 KB
testcase_21 AC 517 ms
4,380 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 8 ms
4,376 KB
testcase_25 AC 4 ms
4,376 KB
testcase_26 AC 74 ms
4,376 KB
testcase_27 AC 102 ms
4,380 KB
testcase_28 AC 223 ms
4,376 KB
testcase_29 AC 77 ms
4,376 KB
testcase_30 AC 398 ms
4,376 KB
testcase_31 AC 3 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 3 ms
4,376 KB
testcase_34 AC 27 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-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