제출 #1088868

#제출 시각아이디문제언어결과실행 시간메모리
1088868SunbaeSavrsen (COCI17_savrsen)C++17
120 / 120
1088 ms39516 KiB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int s[10000001];
ll powr(ll A, int B){
	ll res = 1;
	while(B){
		if(B&1) res *= A;
		A *= A;
		B>>=1;
	}
	return res;
}
signed main(){
	int A, B; scanf("%d %d", &A, &B);
	s[1] = 1; 
	for(int i = 2; i<=B; i+=2) s[i] = 2;
	for(int i = 3; i<=B; i+=2) s[i] = i;
	for(ll i = 3; i<=B; i+=2){
		if(s[i] == i){
			for(ll j = i*i; j<=B; j+=i+i) s[j] = min(s[j], (int)i);
		} 
	}
	ll tot = 0;
	for(int i = A; i<=B; ++i){
		map<int,int> mp;
		ll pd = 1;
		for(int x = i; x > 1; x /= s[x]) mp[s[x]]++;
		for(pair<int,int> it: mp){
			pd *= (powr(it.first, it.second+1) - 1ll)/(it.first-1ll);
		}
		tot += abs(2*i - pd);
	}
	printf("%lld", tot);
}	 

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

savrsen.cpp: In function 'int main()':
savrsen.cpp:15:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  int A, B; scanf("%d %d", &A, &B);
      |            ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...