답안 #633878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
633878 2022-08-23T11:04:27 Z inksamurai Savrsen (COCI17_savrsen) C++17
120 / 120
1138 ms 78660 KB
#include <bits/stdc++.h>
#define int ll
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define vec(...) vector<__VA_ARGS__>
#define _3PGDklf ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
using pii=pair<int,int>;
using vi=vector<int>;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}
// e

const int _n=10000001;

int ps[_n];

signed main(){
_3PGDklf;
	for(int i=1;i<_n;i++){
		for(int j=2*i;j<_n;j+=i){
			ps[j]+=i;
		}
	}
	for(int i=1;i<_n;i++){
		ps[i]=abs(i-ps[i]);
		ps[i]+=ps[i-1];
	}
	int l,r;
	cin>>l>>r;
	print(ps[r]-ps[l-1]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1067 ms 78580 KB Output is correct
2 Correct 1073 ms 78576 KB Output is correct
3 Correct 1119 ms 78580 KB Output is correct
4 Correct 1063 ms 78660 KB Output is correct
5 Correct 1080 ms 78572 KB Output is correct
6 Correct 1063 ms 78580 KB Output is correct
7 Correct 1070 ms 78580 KB Output is correct
8 Correct 1138 ms 78572 KB Output is correct