Submission #3832755

Source Code Expand

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

int main() {
	int N, K;
	scanf("%d%d", &N, &K);
	long long ans = 0;
	for(int i=K+1; i<=N; ++i)
	{
		int div = N/i;
		int rem = N%i;
		ans += 1LL*div*(i-K) + max(rem-K+1, 0);
	}
	if(K==0) ans = 1LL*N*N;
	printf("%lld\n", ans);
	return 0;
}

Submission Info

Submission Time
Task D - Remainder Reminder
User HYEA
Language C++14 (GCC 5.4.1)
Score 400
Code Size 301 Byte
Status
Exec Time 2 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:6:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &K);
                       ^

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
All 400 / 400 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt 2 ms 256 KB
02.txt 2 ms 256 KB
03.txt 1 ms 256 KB
04.txt 2 ms 256 KB
05.txt 2 ms 256 KB
06.txt 2 ms 256 KB
07.txt 1 ms 256 KB
08.txt 1 ms 256 KB
09.txt 2 ms 256 KB
10.txt 1 ms 256 KB
11.txt 1 ms 256 KB
s1.txt 1 ms 256 KB
s2.txt 1 ms 256 KB
s3.txt 1 ms 256 KB