Submission #2204562


Source Code Expand

#include<bits/stdc++.h>
#define L long long
using namespace std;
int t,n,m;
L p;
inline L calc(int a,int b,int c)
{
    if(a>m)
      return (L)(b+1)*m;
    int k=min((m-a)/c,b);
    return (L)a*(k+1)+(L)c*(k+1)*k/2+(L)(b-k)*m;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	//scanf("%d",&t);
	t=1;
	while(t--)
	  {
	   scanf("%d%d",&n,&m);
	   if(!m)
	     {
          printf("%lld\n",(L)n*n);
          continue;
         }
	   m--;
	   p=(L)(m+1)*n;
	   for(i=m+2;i<=n;i=j+1)
	     {
          k=n/i;
          j=n/k;
          p+=(L)(j-i+1)*k*(m+1)+calc(n-j*k,j-i,k);
         }
       p=(L)n*n-p;
       printf("%lld\n",p);
      }
	return 0;
}

Submission Info

Submission Time
Task D - Remainder Reminder
User fateice
Language C++14 (GCC 5.4.1)
Score 400
Code Size 731 Byte
Status AC
Exec Time 1 ms
Memory 256 KiB

Compile Error

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

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 14
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 1 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 1 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