제출 #1105996

#제출 시각아이디문제언어결과실행 시간메모리
1105996dzhoz0Savrsen (COCI17_savrsen)C++17
120 / 120
303 ms78840 KiB
/*
    ghmt the cutie :3
          UwU
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define INF 1e18
#define f first
#define s second
#define pii pair<int, int>
#define vi vector<int>

const int MOD = 1'000'000'000 + 7;

void setIO(string name = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
#ifdef LOCAL
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#else
    if (!name.empty())
    {
        freopen((name + ".INP").c_str(), "r", stdin);
        freopen((name + ".OUT").c_str(), "w", stdout);
    }
#endif
}

const int MAXN = 1e7;

int sumFactor[MAXN + 5];

void init() {
    memset(sumFactor, 0, sizeof(sumFactor));
    for (int p = 1; p * p <= MAXN; p++) {
        sumFactor[p * p] += p;
        for (int q = p + 1; p * q <= MAXN; q++) sumFactor[p * q] += p + q;
    }
}
void solve()
{
    init();
    int l, r; cin >> l >> r;
    int res = 0;
    for(int x = l; x <= r; x++) {
        res += abs(2 * x - sumFactor[x]);
    }
    cout << res << '\n';
}
signed main()
{
    setIO();
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
}

컴파일 시 표준 에러 (stderr) 메시지

savrsen.cpp: In function 'void setIO(std::string)':
savrsen.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen((name + ".INP").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
savrsen.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen((name + ".OUT").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...