提出 #7144103


ソースコード 拡げる

#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);
// }

提出情報

提出日時
問題 D - Remainder Reminder
ユーザ LayCurse
言語 C++14 (GCC 5.4.1)
得点 400
コード長 1434 Byte
結果 AC
実行時間 2 ms
メモリ 256 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 14
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
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