Submission #729645

#TimeUsernameProblemLanguageResultExecution timeMemory
729645danikoynovStrange Device (APIO19_strange_device)C++14
0 / 100
5015 ms524288 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const int maxn = 1e6 + 10; int n; ll l[maxn], r[maxn]; ll A, B; void solve() { cin >> n >> A >> B; for (int i = 1; i <= n; i ++) { cin >> l[i] >> r[i]; } ll g = __gcd(A, B + 1); /// period is A * B / g /**if ((double)(1e18) / (double)(A) < (double)(B) / (double)(g)) { ll ans = 0; for (int i = 1; i <= n; i ++) { ans = ans + (r[i] - l[i] + 1); } cout << ans << endl; return; }*/ double period = A * B / g; unordered_set < ll > st; for (int i = 1; i <= n; i ++) { for (ll j = l[i]; j <= r[i]; j ++) { ll x = (j + (j / B)) % A, y = j % B; ///cout << x << " " << y << endl; st.insert({x * B + A}); } } cout << st.size() << endl; } int main() { solve(); return 0; } /** 1 10000 3312452154131231 1 1 */

Compilation message (stderr)

strange_device.cpp: In function 'void solve()':
strange_device.cpp:49:44: warning: unused variable 'y' [-Wunused-variable]
   49 |                  ll x = (j + (j / B)) % A, y = j % B;
      |                                            ^
strange_device.cpp:42:12: warning: unused variable 'period' [-Wunused-variable]
   42 |     double period = A * B / g;
      |            ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...