Source stringclasses 1
value | Date int64 2.01k 2.02k | Text stringlengths 22 783k | Token_count int64 20 394k |
|---|---|---|---|
Project_CodeNet | 2,020 | #include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string... | 930 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.be... | 394 |
Project_CodeNet | 2,018 | #include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#incl... | 821 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
int main()
{
int N, K;
cin >> N >> K;
long long ans = 0;
for (int i = max(1, K); i <= N; i++) {
int last;
for (int j = 1; j <= i; j = last+1) {
last = i/(i/j);
int R = (i-K)/(i/j);
if (R >= j) {
ans += min(R, last)-j+1;
// cerr << i << " " << j << ... | 163 |
Project_CodeNet | 2,019 | #include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,i,j,x,ans;
int main(){
scanf("%lld%lld",&n,&m);
if(!m){
printf("%lld",n*n);
return 0;
}
for(i=1;i<=n-m;i++){
x=i+m;
ans+=n/x*i;
if(n%x>=m)ans+=n%x-m+1;
}
printf("%lld",ans);
} | 102 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<... | 495 |
Project_CodeNet | 2,018 | #include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#includ... | 419 |
Project_CodeNet | 2,018 | #include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(... | 476 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define memc(a,b) memcpy(a,b,sizeof(b))
#define rep(i,a,n) for(int i=a;i<n;i++) ///[a,n)
#define pb push_back
#define IO ios::sync_with_stdio(false)
#define fre freopen("in.txt","r",stdin)
#define lson l,m,rt<<1
#define rson m+1,r,rt<... | 313 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
ll N, K;
cin >> N >> K;
ll B, ans = 0;
for (B = K + 1; B <= N; B++){
ll num = (((N - B + 1) / B) + 1), z = 0;
ans += (B - K) * num;
ans += max(z, N - K + 1 - B * num);
}
if (K == 0){
ans -= N;
}
... | 138 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
int n, k;
int main(){
scanf("%d%d", &n, &k);
long long res = 0;
for(int i = k + 1; i <= n; i++){
int mx = floor(n / i);
int lt = n % i;
res += 1LL * mx * (i - k);
if(k == 0)
res--;
res += max(0, lt - k + 1);
}
printf("%lld\n", res);
}
| 122 |
Project_CodeNet | 2,019 | /**
*
*/
// header {{{
#include <bits/stdc++.h>
using namespace std;
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#ifdef __SIZEOF_INT128__
using i128 = __int128;
using u128 = unsigne... | 8,877 |
Project_CodeNet | 2,019 | #include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.... | 550 |
Project_CodeNet | 2,018 | #include<cstdio>
long long int max(long long int a,long long int b){
if(a<b)return b;
else return a;
}
int main(){
long long int n,k;
scanf("%lld%lld",&n,&k);
long long int ans=0;
for(int i=k+1;i<=n;i++){
ans+=(n/i)*(i-k)+max((n%i)-k+1,0);
}
if(k==0)ans=n*n;
printf("%lld\n",ans);
return 0;
} | 108 |
Project_CodeNet | 2,019 | //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <io... | 350 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using P = pair<ll,ll>;
int main(){
ll n,k;cin >>n>>k;
ll ans=0;
for (int b =k+1; b <=n ; ++b) {
ans+=(n/b)*(b-k);
ans... | 153 |
Project_CodeNet | 2,019 | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
using namespace std;
//#define... | 496 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);ci... | 469 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) beg... | 678 |
Project_CodeNet | 2,018 | #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define N 100005
#define ll long long
#define db double
#define dbg(x) cout<<#x<<"="<<x<<"\n"
int n,m;ll ans;
int... | 163 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll N, K; cin >> N >> K;
ll ans = 0;
for (int k = K; k < N; ++k) {
ll a = (k - K + 1);
ll b = min(N, (N - K + 1)) / (k + 1);
ll c = min(a, min(N, (N - K + 1)) % (k + 1));
ans += a * b + c;
}
... | 139 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#define fi first
#define se second
#define pb push_back
#define last(s) (s)[(s).size()-1]
#define all(a) (a).begin(),(a).end()
#define elif else if
#define left asdasd
#define next zaza
#define prev azaz
#define cclear cout<<flush;... | 579 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(a) begin(a), end(a)
#define SZ(a) ((int)(a).size())
#define rep(i, n) for (int i = 0; i < n; i++)
#ifdef __DEBUG
#define debug if (true)
#else
#define debug if (false)
#endif
typedef... | 333 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define S... | 352 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl
template<class T> bool set_min... | 578 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;
#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
int main(int argc, char **argv)
{
ll N, K;
cin >> N >> K;
ll res{0};
for (ll b ... | 193 |
Project_CodeNet | 2,018 | #include<iostream>
#include<cstdio>
using namespace std;
long long n,k,ans,t;
int main()
{
cin>>n>>k;
for (long long i=k+1;i<=n;i++)
{
ans+=(n/i)*(i-k);
t=n%i;
if (t>=k) ans+=(t-k+1);
}
if (!k) ans-=n;
cout<<ans<<endl;
return 0;
} | 93 |
Project_CodeNet | 2,018 | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
using namespace std;
long long a,b,n,k,ans;
int main()
{
scanf("%lld%lld",&n,&k);
if (k==0) {
cout<<n*n;
return 0;
}
for (int i=k+1;i<=n;i++)
{
... | 132 |
Project_CodeNet | 2,018 | #include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
ll n, k, x, i, ans;
int main()
{
cin >> n >> k;
for (i = k + 1; i <= n; i++) {
x = n / i;
ans += x * (i - k);
if (k == 0) ans += n - (x * i);
else ans += max(0LL, n - (x * i + k) + 1);
}
cout << ans;
return 0;
}
| 122 |
Project_CodeNet | 2,018 | #include <iostream>
long long int f(long long int n, long long int k, long long int b) {
if (k >= b) return 0;
auto q = n / b;
auto r = n % b;
if (k == 0) return q * b + r;
if (k <= r) return q * (b - k) + (r - k + 1);
else return q * (b - k);
}
int main() {
long long int n, k;
std::cin >> n >> k;
long long i... | 163 |
Project_CodeNet | 2,018 | #define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cma... | 641 |
Project_CodeNet | 2,018 | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, k, ans;
int main()
{
cin >> n >> k;
if(k == 0) {
cout << n * n;
return 0;
}
for(ll i=k+1;i<=n;i++) {
for(ll j=0;j<=n;j+=i) {
ans += max(0ll, min(i-1, n-j) - k + 1);
}
}
cout << ans;
}
| 111 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forrn(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define PYMOD(a, m) ((((a) % (m)) + (m)) % (m))
#define all(v) v.begin(), v.end()
#define mp make_pair
#define... | 339 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define fr first
#define sc second
int main(){
ll n,k;
cin >> n >> k;
if(k == 0){
cout << n*n << endl;
return 0;
}
ll ret = 0;
for(ll b = k+1 ; b <= n ; b ++){
ll x = (n+1)/b;
ll y = (n+1)%b;
ret += x*(b-... | 135 |
Project_CodeNet | 2,018 | # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include... | 461 |
Project_CodeNet | 2,019 | #include<bits/stdc++.h>
using namespace std;
int main(){
int64_t N, K;
cin >> N >> K;
int64_t ans = 0;
if(K == 0){
ans = N*N;
}
else{
for(int64_t i=K+1; i<=N; i++){
ans += N/i *(i-K);
if(N %i >= K){
ans += N%i -(K-1);
}
}
}
cout << ans << endl;
} | 113 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,((n)+1))
#define repst(i,s,n) reps(i,s,((n)+1))
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each... | 901 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
#define FOR(i,k,n) for(int i = (k);i < (n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)
using namespace std;
using vecint = vector<int>;
using ll = int64_t;
int main()
{
int n, k;
cin>>n>>k;
int64_t count = 0;
if (k == 0) {
cout << (int64_t)n * n << end... | 175 |
Project_CodeNet | 2,018 | #include<bits/stdc++.h>
#define ll long long
ll n,k,ans;
using namespace std;
int main()
{
scanf("%lld%lld",&n,&k);
if(k==0){
cout<<n*n<<endl;
return 0;
}
for(int b=k+1;b<=n;++b)
{
ans+=(b-k)*(n/b);
ans+=max((ll)0,n%b-k+1);
}
cout<<ans;
}
| 102 |
Project_CodeNet | 2,019 | #include <iostream>
#include <algorithm>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
long long ans = 0;
for (int b = K + 1; b <= N; b++) ans += (N + 1)/b*(b - K) + max(0, (N + 1)%b - K);
if (!K) ans -= N;
cout << ans << endl;
return 0;
} | 105 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
int n, k;
cin >> n >> k;
ll ans = 0;
for (int b = k + 1; b <= n; b++) {
int q = (n - k) / b;
int r = min(n - q * b, b - 1);
ans += (ll)(b - k) * q;
ans += r - k... | 144 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
int main()
{
long long n,k,ans=0;
cin >> n>> k;
if(k==0) ans=n*n;
else
{
for(int b=k+1;b<=n;b++)
{
ans+=(n/b)*(b-k);
if(n%b>=k) ans+=n%b-k+1;
}
}
printf("%lld\n",ans);
return 0;
}
| 105 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()... | 204 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin >> n >> k;
long long int fans = 0;
for(int i = 1; i <= n; i++) //b
{
int cur = i;
int times = n / i;
int left = n % i;
int get = max(0,i - k);
fans += get * 1ll * times;
if(!k)
... | 136 |
Project_CodeNet | 2,020 | {for(b=$2;t=int($1/++b);s+=++c*t+a)a*=0<a=$1%b-$2+!!$2}$0=s | 36 |
Project_CodeNet | 2,018 | n,k=map(x->parse(Int,x),split(readline()))
c=0
n+=1
for b=k+1:n-1
c+=div(n,b)*(b-k)
if k==0
c-=1
end
if div(n,b)*b+k<n
c+=n-div(n,b)*b-k
end
end
println(c)
| 79 |
Project_CodeNet | 2,019 | #include<stdio.h>
int main(void){
char *s="python3 -c\""
"n,k=map(int,input().split())\n"
"a=(n-k)*(n-k+1)//2\n"
"for i in range(k+1,n):\n"
" j=n//i*i\n"
" a+=(j//i-1)*(i-k)+max(n-j+1-max(k,1),0)\n"
"print(a)\n"
"\"";
system(s);
return 0;
} | 112 |
Project_CodeNet | 2,020 | //Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
obj = init(inLine);
console.error("\n... | 585 |
Project_CodeNet | 2,018 | fun main(args: Array<String>){
val line: String = readLine() as String
val nm=line.split(" ")
val n = nm[0].toInt()
val k = nm[1].toInt()
var count:Long = 0
for(b in k+1..n){
count+=(n/b)*(b-k)
if(n%b-k+1>0){
count +=( n%b-k+1)
}
}
if(k==0)count-=n
... | 116 |
Project_CodeNet | 2,020 | fun main(arr: Array<String>) {
val (n,k) = readLine()!!.split(" ").map { it.toInt() }
var ans = 0L
for(i in (k+1..n)) {
val min = 0
var max = (n / i)
if(max*i+k > n) {
max--
}
ans += (max-min)*(i-k)
ans += Math.min(i*(max+1)-1, n) - (i*max+k)+1
... | 134 |
Project_CodeNet | 2,020 | import java.io.*
val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L
fun main(args: Array<String>) {
solve()
pw.flush()
}
fun solve() {
val (n, k) = nextLongList()
if(k == 0L){
println(n * n)
return
}
v... | 967 |
Project_CodeNet | 2,018 | fun main(args: Array<String>) {
val (n, k) = readLine()!!.split(" ").map(String::toInt)
if (k == 0) {
println(n.toLong() * n.toLong())
return
}
var ans = 0L
for (b in (k + 1)..n) {
ans += (b - k).toLong() * (n / b).toLong()
ans += Math.max((n % b) - (k - 1), 0)
}
println(ans)
}
| 122 |
Project_CodeNet | 2,020 | //
fun main() {
arc091b()
}
fun arc091b() {
val (n, k) = readLine()!!.split(" ").map { it.toInt() }
var count = 0L
for (b in k + 1..n) {
val nn = if (k == 0) n else n + 1
val cycle = nn / b
var c = cycle * (b - k)
val remain = nn % b
if (remain > k) {
... | 134 |
Project_CodeNet | 2,020 | fun main(args: Array<String>){
val (N, K) = readLine()!!.split(" ").map { it.toLong() }
if(K == 0L){
println(N * N)
return
}
var ans = 0L
for(b in 1..N){
val div = N / b
val rem = N % b
ans += div * (Math.max(0, b - K))
ans += Math.max(0, rem - K + 1)
... | 119 |
Project_CodeNet | 2,019 | import java.util.*
fun main(args: Array<String>){
val cin = Scanner(System.`in`)
val n = cin.nextInt()
val k = cin.nextInt()
var ans: Long = 0
for (b in k+1..n) {
val x_max = n / b
val r_min = k
val r_max = b - 1
ans += x_max * (r_max - r_min + 1)
val exd = n - b... | 163 |
Project_CodeNet | 2,018 | private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }
private fun Long.positiveOrZero() = if (this > 0) this else 0
fun main(args: Array<String>) {
val (N, K) = readInts().map { it.toLong() }
if (K == 0L) return println(N * N)
val suchPairsNum = (2.... | 149 |
Project_CodeNet | 2,020 | import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*
fun PrintWriter.solve(sc: FastScanner) {
val n = sc.nextInt()
val k = sc.nextInt()
var ans = 0L
if (k == 0) {
ans = n.toLong() *... | 282 |
Project_CodeNet | 2,019 | fun main(args: Array<String>) {
val (n, k) = readLine()!!.split(' ').map(String::toLong)
var ans = 0L
if (k == 0L) {
println(n * n)
return
}
for (b in (k + 1)..n) {
val last = n % b
val countK = Math.min(n / b + if (last >= k) 1 else 0, n)
val leftSmaller = co... | 165 |
Project_CodeNet | 2,020 | import kotlin.math.max
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main() {
val (n, k) = intList()
var c = 0L
if (k == 0) {
println((n.toLong() * n.toLong()).toString())
return
}
1.until(n + 1).forEach {
val p = n / it
val r = n % it
... | 136 |
Project_CodeNet | 2,020 | fun main(args: Array<String>) = yorukatsu10d()
fun yorukatsu10d() {
val (n, k) = readLine()!!.split(' ').map { it.toLong() }
if (k == 0L) return println(n * n)
var answer = 0L
for (b in k + 1..n) {
answer += (n / b) * (b - k) + Math.max(n % b - k + 1, 0)
}
println(answer)
}
| 118 |
Project_CodeNet | 2,020 | main = do
[n,k] <- map read . words <$> getLine :: IO [Int]
let ans | k == 0 = n ^ 2
| otherwise = sum $ map (\b -> let (p,r) = n `divMod` b in p * (max 0 (b-k)) + max 0 (r-k+1)) [1..n]
print ans | 87 |
Project_CodeNet | 2,018 | main = getLine >>= print . solve . map read . words
solve (n:k:_)
| k == 0 = n * n
| otherwise = sum [((n + 1) `div` b) * (b - k) + max 0 ((n + 1) `mod` b - k) | b <- [k + 1..n]] | 82 |
Project_CodeNet | 2,020 | --{-# LANGUAGE BangPatterns #-}
--{-# LANGUAGE ScopedTypeVariables #-}
--{-# LANGUAGE FlexibleContexts #-}
--{-# LANGUAGE ViewPatterns #-}
--{-# LANGUAGE OverloadedStrings #-}
--{-# LANGUAGE Strict #-}
--{-# LANGUAGE NumericUnderscores #-}
--{-# LANGUAGE BlockArguments #-}
--{-# LANGUAGE MultiWayIf #-}
import qualifie... | 1,726 |
Project_CodeNet | 2,020 | import Control.Applicative
import Control.DeepSeq
import Control.Monad
import Control.Monad.ST
import qualified Data.Array as A
import qualified Data.Array.IArray as IA
import qualified Data.Array.IO as AI
import qualified Data.Array... | 839 |
Project_CodeNet | 2,019 | n,k=io.read("*n","*n")
ans=0
if (k==0) then
ans=n*n
else
for i=k,n do
ans=ans+(i-k)*(n//i)
if (n%i>=k) then
ans=ans+(n%i)-k+1
print(ans) | 74 |
Project_CodeNet | 2,020 | program arc091_d
use,intrinsic :: iso_fortran_env
implicit none
integer(int64):: n,k,b,ans=0
read*, n,k
do b = k+1,n
ans=ans+(n/(b)*(b-k))+max((n-((n/b)*b+k)+1),0)
end do
if (k==0) ans=ans-n
print'(i0)', ans
end program arc091_d | 104 |
Project_CodeNet | 2,020 | ?sKdsNlK-[ddlK+lNr~lK-1dlK+%+k*K+0kr1-d0<x+]dsxxp | 33 |
Project_CodeNet | 2,020 | ?sKdsNlK-[ddlK+lNr~lK-0lK^-1+k*K+0kr1-d0<x+]dsxxp | 33 |
Project_CodeNet | 2,018 | object Main extends App {
val sc = new java.util.Scanner(System.in)
val N, K = sc.nextLong
var sum :Long = 0
if (K == 0) {
println(N * N)
sys.exit
}
for (b <- K + 1 to N) {
val x = N % b
if (x >= K) {
sum += (b - K) * (N / b) + x + 1 - K
} else {
sum += (b - K) * (N / b)
... | 134 |
Project_CodeNet | 2,018 | import java.util.Scanner
object Main {
def solve(): Unit = {
val sc = new Scanner(System.in)
val N = sc.nextLong()
val K = sc.nextLong()
val sum = K match {
case 0 => N * N
case _ => ((K + 1 to N) map { b =>
(N / b) * (b - K) + math.max(N % b - K + 1, 0)
}).sum
}
pri... | 128 |
Project_CodeNet | 2,020 | object Main extends App {
val sc = new java.util.Scanner(System.in)
val n, k = sc.nextInt()
if (k == 0) {
println(n.toLong * n)
} else {
var ans = 0L
for (b <- k+1 to n) {
ans += ((n - k + 1) / b) * (b-k)
ans += ((n - k + 1) % b).min(b-k)
}
println(ans)
}
}
| 112 |
Project_CodeNet | 2,020 | Scanf.scanf "%d %d" @@ fun n k ->
let rec f i s =
if i = n + 1 then s
else
let j = (n - k) / i in
f (i + 1) (s - k * (j + 1) + min (n + 1) (i * (j + 1))) in
let ans = f (k + 1) (if k = 0 then k - n else 0) in
Printf.printf "%d\n" ans
| 123 |
Project_CodeNet | 2,018 | let () = Printf.printf "%d\n" @@ Scanf.scanf "%d %d" (fun n k ->
Array.init n (( + ) 1)
|> Array.map (fun b ->
max 0 (b - k) * (n / b)
+ min (n mod b) (max 0 (n mod b - k + 1)))
|> Array.fold_left ( + ) 0) | 90 |
Project_CodeNet | 2,018 | use std::cmp::{max, min};
fn read_line() -> String {
let mut s = String::new();
std::io::stdin().read_line(&mut s).unwrap();
s.trim().to_owned()
}
fn reads<T>() -> Vec<T>
where
T: std::str::FromStr,
<T as std::str::FromStr>::Err: std::fmt::Debug,
{
read_line()
.split_whitespace()
... | 266 |
Project_CodeNet | 2,020 | // -*- coding:utf-8-unix -*-
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::LinkedList;
use std::collections::VecDeque;
use std::fs::File;
use std::io;
use std::io::prelud... | 992 |
Project_CodeNet | 2,020 | #![allow(unused_imports, unused_macros, dead_code)]
macro_rules! min {
(.. $x:expr) => {{
let mut it = $x.iter();
it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
}};
($x:expr) => ($x);
($x:expr, $($ys:expr),*) => {{
let t = min!($($ys),*);
if $x < t { $x } else { t }
... | 761 |
Project_CodeNet | 2,018 | use std::io;
use std::cmp;
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {
let mut buf = String::new();
io::stdin().read_line(&mut buf).unwrap();
buf.split(' ')
.map(|s| s.trim().parse().unwrap())
.collect()
}
fn main() {
let (n, k) = {
... | 293 |
Project_CodeNet | 2,019 | #[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
($($r:tt)*) => {
let stdin = std::io::stdin();
let mut bytes = std::io::Read::bytes(std::io::BufRea... | 780 |
Project_CodeNet | 2,020 | #![allow(unused_macros)]
// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
(source = $s:expr, $($r:tt)*) => {
let mut iter = $s.split_whitespace();
let mut next = || { iter.next().unwrap() };
input_inner!{next, $($r)*}
... | 625 |
Project_CodeNet | 2,020 | #![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
#[allow(unused_macros)]
macro_rules! debug {
($($e:expr),*) => {
#[cfg(debug_assertions)]
$({
let (e, mut err) = (stringify!($e), std::io::stderr());
writeln!(er... | 341 |
Project_CodeNet | 2,019 | #[allow(unused_macros)]
macro_rules! input {
(source = $s:expr, $($r:tt)*) => {
let mut iter = $s.split_whitespace();
let mut next = || { iter.next().unwrap() };
input_inner!{next, $($r)*}
};
($($r:tt)*) => {
let stdin = std::io::stdin();
let mut bytes = std::io::Read... | 5,160 |
Project_CodeNet | 2,020 | extern crate proconio;
use proconio::input;
use std::cmp;
fn count_mod_ge(n:i32, b:i32, k:i32) -> i64 {
let r = n / b;
let m = n % b;
let c = r * (b - k) + cmp::max(m + 1 - k, 0);
match k {
0 => (c - 1) as i64,
_ => c as i64,
}
}
fn main(){
input!{ N: i32, K:i32 }
let ans : i64 = (K + 1 ..= N).i... | 164 |
Project_CodeNet | 2,020 | use proconio::input;
fn main() {
input!(n: u64, k: u64);
println!(
"{}",
if k == 0 {
n * n
} else {
let mut ans = 0;
for b in k + 1..=n {
ans += n / b * (b - k);
ans += (n % b + 1).saturating_sub(k);
}
... | 105 |
Project_CodeNet | 2,020 | // This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;
fn main() {
input! {
n: i64,
k: i64,
... | 109,307 |
Project_CodeNet | 2,020 | // This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
#[allow(unused_imports)]
use std::cmp;
fn run() {
let (r, w) = (std::io::stdin(), std::io::stdout());
let mut sc = IO::new(r.lock(), w.lock());
let n: usize = sc.read();
let k: usize = sc.... | 112,526 |
Project_CodeNet | 2,020 | use proconio::{input, fastout};
#[fastout]
fn main() {
input! {
n: usize,
k: usize,
}
let mut count = 0;
for b in 1..=n {
if b > k {
let d = n / b;
let r = n % b;
count += (b - k) * d;
if r >= k {
count += r - k... | 126 |
Project_CodeNet | 2,018 | use std::io::{BufRead, Write};
use std::io;
fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
let mut buf = String::new();
input.read_line(&mut buf).unwrap();
let (n, k): (usize, usize) = {
let mut split = buf.split_whitespace();
(split.next().unwrap().parse().unwrap(), split.ne... | 351 |
Project_CodeNet | 2,018 | use std::str::FromStr;
use std::io::*;
pub fn main() {
let i = stdin();
let mut o = Vec::new();
run(&mut i.lock(), &mut o);
stdout().write_all(&o).unwrap();
}
fn run<R: BufRead, W: Write>(i: &mut R, o: &mut W) {
let mut i = AtRead::from(i);
let (n, k) = i.read2::<usize, usize>();
writeln!(... | 506 |
Project_CodeNet | 2,018 | #[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::usize;... | 471 |
Project_CodeNet | 2,020 | use std::io::Read;
fn main() {
let mut buf = String::new();
std::io::stdin().read_to_string(&mut buf).unwrap();
let answer = solve(&buf);
println!("{}", answer);
}
fn solve(input: &str) -> String {
let mut iterator = input.split_whitespace();
let n: usize = iterator.next().unwrap().parse().... | 201 |
Project_CodeNet | 2,018 | use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min
#[allow(dead_code)]
fn read_line() -> String{
let mut s = String::new();
io::stdin().read_line(&mut s).unwrap();
... | 562 |
Project_CodeNet | 2,020 | #[allow(unused_imports)]
use {
proconio::{fastout, input, marker::*},
std::cmp::*,
std::collections::*,
};
#[fastout]
fn main() {
input! {
n: usize,
k: usize
}
if k == 0 {
println!("{}", n * n);
return;
}
let mut ans = 0;
for b in k + 1..=n {
ans += (b - k) * ... | 140 |
Project_CodeNet | 2,020 | pub trait IterScan: Sized {
type Output;
fn scan<'a, I: Iterator<Item = &'a str>>(iter: &mut I) -> Option<Self::Output>;
}
pub trait MarkedIterScan: Sized {
type Output;
fn mscan<'a, I: Iterator<Item = &'a str>>(self, iter: &mut I) -> Option<Self::Output>;
}
#[derive(Debug)]
pub struct Scanner<'a> {
... | 1,851 |
Project_CodeNet | 2,018 | #![allow(unused_imports, unused_macros, dead_code)]
use std::f64::*;
use std::cmp::*;
use std::collections::*;
macro_rules! dump{
($($a:expr),*) => {
#[cfg(debug_assertions)]
eprintln!(
concat!("{}:{}:{}: ",$(stringify!($a), " = {:?}, "),*),
file!(), line!(), column!(), $($a... | 1,494 |
Project_CodeNet | 2,018 | fn main() {
let mut sc = Scanner::new();
let n: usize = sc.read();
let k: usize = sc.read();
if k == 0 {
println!("{}", n * n);
return;
}
let mut ans = 0;
for b in (k + 1)..(n + 1) {
let unit = b - 1 - k + 1;
let max = (n + 1) / b;
ans += unit * max... | 557 |
Project_CodeNet | 2,020 | // This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*, fastout};
use superslice::*;
#[fastout()]
fn main() {
input! {
n: ... | 128,036 |
Project_CodeNet | 2,018 | use std::io::prelude::*;
fn main() {
let (n, k): (u64, u64) = readln();
let mut answer: u64 = 0;
for b in k + 1..n + 1 {
let mut lb: u64 = 0;
let mut ub: u64 = 1000000;
while ub - lb > 1 {
let mid = (lb + ub) / 2;
let d = k + mid * b;
if d <= n {
... | 5,717 |
Project_CodeNet | 2,018 | /**
* _ _ __ _ _ _ _ _ _ _
* | | | | / / | | (_) | (_) | | (_) | |
* | |__ __ _| |... | 1,357 |
Project_CodeNet | 2,019 | #[allow(unused_macros)]
macro_rules! get {
([$t:ty] ; $n:expr) => {
(0..$n)
.map(|_| get!([$t])).collect::<Vec<_>>()
};
($($t:ty),+ ; $n:expr) => {
(0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
};
([$t:ty]) => {
rl().split_whitespace()
.map(|x| x.parse().... | 380 |
Project_CodeNet | 2,019 | (define (solve)
(let* ((n (read)) (k (read)))
(if (zero? k) (print (* n n))
(let loop ((b (+ k 1)) (q (div (- n k) (+ k 1))) (ans 0))
(cond ((< n b) (print ans))
((<= (* b (+ q 1)) (+ n 1))
(loop (+ b 1) (div (- n k) (+ b 1))
(+ ans (* (- b k) (+ q 1)))))
(else (loop (+ b 1) (div (- n k) (+ b ... | 170 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.