Submission #7144103
Source Code Expand
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
return a>=b?a:b;
}
inline void rd(int &x){
int k, m=0;
x=0;
for(;;){
k = getchar_unlocked();
if(k=='-'){
m=1;
break;
}
if('0'<=k&&k<='9'){
x=k-'0';
break;
}
}
for(;;){
k = getchar_unlocked();
if(k<'0'||k>'9'){
break;
}
x=x*10+k-'0';
}
if(m){
x=-x;
}
}
inline void wt_L(char a){
putchar_unlocked(a);
}
inline void wt_L(long long x){
char f[20];
int m=0, s=0;
if(x<0){
m=1;
x=-x;
}
while(x){
f[s++]=x%10;
x/=10;
}
if(!s){
f[s++]=0;
}
if(m){
putchar_unlocked('-');
}
while(s--){
putchar_unlocked(f[s]+'0');
}
}
int N;
int K;
int main(){
int a, b, i, j;
long long res=0;
rd(N);
rd(K);
for(b=(K+1);b<(N+1);b++){
i = N / b;
j = N % b;
if(K==0){
res += (b-K) * i +max_L(0, j-K+1 -1);
}
else{
res += (b-K) * i +max_L(0, j-K+1);
}
}
wt_L(res);
wt_L('\n');
return 0;
}
// cLay varsion 20190822-2
// --- original code ---
// int N, K;
// {
// int i, j, a, b;
// ll res = 0;
// rd(N,K);
// rep(b,K+1,N+1){
// i = N / b;
// j = N % b;
// res += (b-K) * i + max(0, j-K+1 if[K==0, -1]);
// }
// wt(res);
// }
Submission Info
| Submission Time | |
|---|---|
| Task | D - Remainder Reminder |
| User | LayCurse |
| Language | C++14 (GCC 5.4.1) |
| Score | 400 |
| Code Size | 1434 Byte |
| Status | AC |
| Exec Time | 2 ms |
| Memory | 256 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | s1.txt, s2.txt, s3.txt |
| All | 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 | AC | 1 ms | 256 KiB |
| 02.txt | AC | 1 ms | 256 KiB |
| 03.txt | AC | 1 ms | 256 KiB |
| 04.txt | AC | 1 ms | 256 KiB |
| 05.txt | AC | 2 ms | 256 KiB |
| 06.txt | AC | 1 ms | 256 KiB |
| 07.txt | AC | 1 ms | 256 KiB |
| 08.txt | AC | 1 ms | 256 KiB |
| 09.txt | AC | 2 ms | 256 KiB |
| 10.txt | AC | 1 ms | 256 KiB |
| 11.txt | AC | 1 ms | 256 KiB |
| s1.txt | AC | 1 ms | 256 KiB |
| s2.txt | AC | 1 ms | 256 KiB |
| s3.txt | AC | 1 ms | 256 KiB |