Submission #167355

# Submission time Handle Problem Language Result Execution time Memory
167355 2019-12-07T15:12:36 Z sans Savrsen (COCI17_savrsen) C++14
120 / 120
2260 ms 78712 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

const int N = 1e7+3;

vll arr(N, 1);

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int a, b, B; cin >> a >> B;
    int A = 1;

    arr[1] = 0;
    for(int i = 2; i <= B; ++i)
        for(int j = A+i-A%i; j <= B-B%i; j += i)
            if(j > i) arr[j] += i;

    for(int i = a; i <= B; ++i) arr[i] = abs(i - arr[i]);
    ll total = 0;
    for(int i = a; i <= B; ++i) total += arr[i];
    cout << total << endl;

    return 0;
}

//cikisir

Compilation message

savrsen.cpp: In function 'int main(int, char**)':
savrsen.cpp:37:12: warning: unused variable 'b' [-Wunused-variable]
     int a, b, B; cin >> a >> B;
            ^
# Verdict Execution time Memory Grader output
1 Correct 69 ms 78588 KB Output is correct
2 Correct 67 ms 78584 KB Output is correct
3 Correct 73 ms 78584 KB Output is correct
4 Correct 2149 ms 78672 KB Output is correct
5 Correct 2201 ms 78684 KB Output is correct
6 Correct 2260 ms 78684 KB Output is correct
7 Correct 1956 ms 78664 KB Output is correct
8 Correct 337 ms 78712 KB Output is correct