結果

問題 No.546 オンリー・ワン
ユーザー y_taira_cy_taira_c
提出日時 2017-07-15 00:20:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,094 bytes
コンパイル時間 1,205 ms
コンパイル使用メモリ 105,092 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 20:54:11
合計ジャッジ時間 1,724 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 RE -
testcase_09 WA -
testcase_10 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <sstream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <chrono>
#include <unordered_map>



using namespace std;

typedef long long int ll;

#define REP(i,n) for(int i=0; i<(n); ++i )
#define REPR(i,n) for(int i=(n); i>=0; --i)
#define FOR(i,a,n) for(int i=(a); i<(n); ++i )
#define FORR(i,a,n) for(int i=(n); i>=(a); --i)

#define DOUT(x) cerr << #x << " = " << (x) << "\n";
#define COUT(x) cout << (x) << "\n";

signed main()
{
	ll n, l, h;
	cin >> n >> l >> h;
	unordered_map<ll, ll> a;
	unordered_map<ll, ll> b;
	set<ll> c;

	REP(i, n)
	{
		cin >> a[1 << i];
		c.insert(a[1 << i]);
	}
	int cnt = 0;

	FOR(i, 1, 1 << n)
	{
		int x = 1;
		REP(j, n)
		{
			if (a.count(i & (1 << j)) == 0)continue;
			x *= a[i &(1 << j)];
		}
		b[x] = h / x - (l-1)/x;
		
	}

	for (auto i = b.begin(); i != b.end(); ++i)
	{
		if (c.count(i->first))
		{
			cnt += i->second;
		}
		else
		{
			int x = 0;
			REP(k, n)
			{
				if (i->first % a[1 << k] == 0)x++;
			}
			cnt -= i->second*x;
		}
	}
	COUT(cnt);
}

0