답안 #631284

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
631284 2022-08-18T02:35:24 Z TranGiaHuy1508 Brunhilda’s Birthday (BOI13_brunhilda) C++17
8.09524 / 100
32 ms 1356 KB
/*
	Unknown's C++ Template (v3.2)
*/
 
#include "bits/stdc++.h"
using namespace std;
 
#define int long long
 
using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvii = vector<vii>;
template <class T> using maxpq = priority_queue<T>;
template <class T> using minpq = priority_queue<T, vector<T>, greater<T>>;
 
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mid ((l+r)>>1)
#define fi first
#define se second
 
#ifdef LOCAL
	#define debug(x) cout << #x << " = " << x << "\n";
#else
	#define debug(x) ;
#endif
 
template <class A, class B>
ostream& operator << (ostream& out, pair<A, B> x)
{ out << "(" << x.first << ", " << x.second << ")"; return out; }
 
template <class T>
ostream& operator << (ostream& out, vector<T> x){
	out << "[";
	for (int i=0; i<sz(x); i++) { out << (i ? ", " : "") << x[i]; }
	out << "]"; return out;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &x){
	for (auto &i: x) in >> i;
	return in;
}
 
const ld PI = acos(-1.0);
const int allmod[3] = {(int)1e9+7, 998244353, (int)1e9+9};
const int mod = allmod[0];
const int maxn = 2e5 + 64;
const ll inf = 1e18;
const ld eps = 1e-6;
const int multitest = 0;
 
const int maxval = 1e7;
 
void main_program(){
	int m, q; cin >> m >> q;
	vi v(m); cin >> v; sort(all(v), greater<int>());
 
	int LCM = 1;
	for (int i = 0; i < m; i++){
		LCM = lcm(LCM, v[i]);
		if (LCM > maxval) break;
	}
 
	for (int i = 0; i < q; i++){
		int x; cin >> x;
		if (x >= LCM){
			cout << "oo\n";
			continue;
		}
 
		int res = 0;
		if (x % v[0]) res++;
		x -= x % v[0];
 
		int j = 0, crr = 2;
		while (x){
			x /= v[j];
			j++;

			if (j >= m) break;
 
			res += crr * (x % v[j]);
			crr *= v[j];
			x -= x % v[j];
		}
 
 		if (x) cout << "oo\n";
		else cout << res << "\n";
	}
}
 
void pre_main(){
 
}
 
signed main(){
	#ifdef LOCAL
		auto stime = chrono::high_resolution_clock::now();
	#endif
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
		if (fopen(".inp", "r")){
			freopen(".inp", "r", stdin);
			freopen(".out", "w", stdout);
		}
	#endif
	int t = 1; if (multitest) cin >> t;
	pre_main();
	while (t--) main_program();
	#ifdef LOCAL
		auto etime = chrono::high_resolution_clock::now();
		auto duration = chrono::duration_cast<chrono::milliseconds>(etime-stime).count();
		cout << "\n[" << duration << "ms]\n";
	#endif
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:109:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  109 |    freopen(".inp", "r", stdin);
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~
brunhilda.cpp:110:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  110 |    freopen(".out", "w", stdout);
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Incorrect 2 ms 340 KB Output isn't correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Incorrect 0 ms 212 KB Output isn't correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Incorrect 0 ms 212 KB Output isn't correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Correct 0 ms 212 KB Output is correct
13 Incorrect 1 ms 212 KB Output isn't correct
14 Incorrect 2 ms 340 KB Output isn't correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 Incorrect 1 ms 212 KB Output isn't correct
17 Incorrect 2 ms 340 KB Output isn't correct
18 Incorrect 2 ms 340 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Correct 9 ms 980 KB Output is correct
3 Correct 6 ms 852 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Correct 5 ms 724 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 1 ms 340 KB Output isn't correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Incorrect 7 ms 852 KB Output isn't correct
10 Correct 8 ms 852 KB Output is correct
11 Incorrect 5 ms 596 KB Output isn't correct
12 Incorrect 1 ms 212 KB Output isn't correct
13 Incorrect 1 ms 340 KB Output isn't correct
14 Incorrect 1 ms 340 KB Output isn't correct
15 Incorrect 4 ms 596 KB Output isn't correct
16 Correct 13 ms 980 KB Output is correct
17 Incorrect 1 ms 340 KB Output isn't correct
18 Incorrect 9 ms 1108 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 724 KB Output isn't correct
2 Incorrect 8 ms 724 KB Output isn't correct
3 Incorrect 12 ms 884 KB Output isn't correct
4 Incorrect 20 ms 556 KB Output isn't correct
5 Incorrect 29 ms 1184 KB Output isn't correct
6 Incorrect 16 ms 640 KB Output isn't correct
7 Incorrect 17 ms 1108 KB Output isn't correct
8 Incorrect 11 ms 724 KB Output isn't correct
9 Incorrect 11 ms 768 KB Output isn't correct
10 Incorrect 2 ms 340 KB Output isn't correct
11 Incorrect 4 ms 340 KB Output isn't correct
12 Incorrect 4 ms 340 KB Output isn't correct
13 Incorrect 17 ms 928 KB Output isn't correct
14 Incorrect 21 ms 788 KB Output isn't correct
15 Incorrect 5 ms 340 KB Output isn't correct
16 Incorrect 4 ms 340 KB Output isn't correct
17 Incorrect 6 ms 596 KB Output isn't correct
18 Incorrect 9 ms 744 KB Output isn't correct
19 Incorrect 4 ms 340 KB Output isn't correct
20 Incorrect 17 ms 852 KB Output isn't correct
21 Incorrect 17 ms 932 KB Output isn't correct
22 Incorrect 23 ms 1356 KB Output isn't correct
23 Incorrect 17 ms 864 KB Output isn't correct
24 Incorrect 14 ms 616 KB Output isn't correct
25 Incorrect 14 ms 596 KB Output isn't correct
26 Incorrect 14 ms 572 KB Output isn't correct
27 Incorrect 17 ms 1108 KB Output isn't correct
28 Incorrect 16 ms 724 KB Output isn't correct
29 Incorrect 27 ms 1296 KB Output isn't correct
30 Incorrect 32 ms 1124 KB Output isn't correct
31 Incorrect 15 ms 484 KB Output isn't correct
32 Incorrect 19 ms 604 KB Output isn't correct
33 Incorrect 15 ms 588 KB Output isn't correct
34 Incorrect 17 ms 1188 KB Output isn't correct
35 Incorrect 16 ms 644 KB Output isn't correct
36 Incorrect 22 ms 1160 KB Output isn't correct
37 Incorrect 23 ms 1252 KB Output isn't correct
38 Incorrect 15 ms 652 KB Output isn't correct
39 Incorrect 16 ms 644 KB Output isn't correct
40 Incorrect 15 ms 548 KB Output isn't correct
41 Correct 17 ms 1236 KB Output is correct
42 Incorrect 16 ms 720 KB Output isn't correct