#include<bits/stdc++.h> using namespace std; int main(){ long long n,k,s=0;//开longlong保险 cin>>n>>k; long long y=k+1; for(int i=0;i<k;i++){//循环k次 s+=(n/y)*(n-n/y);//使用计数器 n-=n/y;//减去已经用过的值 y--;//可以分解的次数-- } cout<<s;//输出答案 return 0; }
扫描二维码,关注牛客
下载牛客APP,随时随地刷题
全部评论
(1) 回帖