結果

問題 No.2211 Frequency Table of GCD
ユーザー achapiachapi
提出日時 2023-02-11 03:28:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,154 ms / 2,000 ms
コード長 1,217 bytes
コンパイル時間 4,743 ms
コンパイル使用メモリ 265,592 KB
実行使用メモリ 5,540 KB
最終ジャッジ日時 2023-09-22 03:17:38
合計ジャッジ時間 17,311 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 253 ms
4,388 KB
testcase_04 AC 370 ms
4,408 KB
testcase_05 AC 531 ms
4,852 KB
testcase_06 AC 384 ms
4,752 KB
testcase_07 AC 544 ms
4,856 KB
testcase_08 AC 30 ms
4,376 KB
testcase_09 AC 23 ms
4,380 KB
testcase_10 AC 67 ms
4,380 KB
testcase_11 AC 44 ms
4,376 KB
testcase_12 AC 73 ms
4,380 KB
testcase_13 AC 331 ms
4,624 KB
testcase_14 AC 394 ms
4,656 KB
testcase_15 AC 321 ms
4,740 KB
testcase_16 AC 370 ms
4,652 KB
testcase_17 AC 486 ms
4,656 KB
testcase_18 AC 739 ms
5,376 KB
testcase_19 AC 741 ms
5,448 KB
testcase_20 AC 735 ms
5,432 KB
testcase_21 AC 741 ms
5,452 KB
testcase_22 AC 740 ms
5,428 KB
testcase_23 AC 268 ms
4,588 KB
testcase_24 AC 1,151 ms
5,540 KB
testcase_25 AC 39 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 729 ms
5,524 KB
testcase_28 AC 1,154 ms
5,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
using mint = modint998244353;
//using mint = modint1000000007;
#define all(...) std::begin(__VA_ARGS__), std::end(__VA_ARGS__)
#define rall(...) std::rbegin(__VA_ARGS__), std::rend(__VA_ARGS__)
#define debug(x) cerr << "\033[33m(line:" << __LINE__ << ") " << #x << ": " << x << "\033[m" << endl;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using Graph=vector<vector<int>>;
const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main() {
	int n,m;cin>>n>>m;
	vector<int> a(n);
	vector<int> b(m+1);
	for(int i=0;i<n;i++){
		cin>>a[i];
		set<int> s;
		for(int j=1;j*j<=a[i];j++){
			if(a[i]%j==0){
				s.insert(j);
				s.insert(a[i]/j);
			}
		}
		for(int j:s){
			b[j]++;
		}
	}
	vector<mint> c(m+1);
	for(int i=1;i<=m;i++){
		mint ans=2;
		ans=ans.pow(b[i]);
		ans-=1;
		c[i]=ans;
	}
	for(int i=m;i!=0;i--){
		for(int j=i*2;j<=m;j+=i){
			c[i]-=c[j];
		}
	}
	for(int i=1;i<=m;i++){
		cout<<c[i].val()<<endl;
	}
}
0