zoukankan      html  css  js  c++  java
  • P2261-余数求和

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 typedef long long ll;
     4 typedef double db;
     5 #define INF 0x3f3f3f3f
     6 #define _for(i,a,b) for(int i = (a);i < b;i ++)
     7 #define _rep(i,a,b) for(int i = (a);i > b;i --)
     8 #define mod 20100403
     9 
    10 inline ll read()
    11 {
    12     ll ans = 0;
    13     char ch = getchar(), last = ' ';
    14     while(!isdigit(ch)) last = ch, ch = getchar();
    15     while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
    16     if(last == '-') ans = -ans;
    17     return ans;
    18 }
    19 inline void write(ll x)
    20 {
    21     if(x < 0) x = -x, putchar('-');
    22     if(x >= 10) write(x / 10);
    23     putchar(x % 10 + '0');
    24 }
    25 
    26 ll N,K;
    27 int main()
    28 {
    29     N = read();
    30     K = read();
    31     ll ans = 0,t,r;
    32     for(ll l = 1;l < N+1;l = r+1)
    33     {
    34         t = K/l;
    35         if(!t)
    36             r = N;
    37         else
    38             r = min(K/t,N);
    39         ans -= (t * (r - l + 1) * (l + r)/2);
    40     }
    41     write(ans + N*K);
    42     return 0;
    43 }
  • 相关阅读:
    CSS—BFC学习
    JS函数声明及函数表达式相关
    你想要的正则表达式笔记
    WordPress搭建自己的网站
    声纹识别
    WordPress搭建自己的网站
    L--jsp和servlet
    L--网页跳转
    L1--指针
    L--Java关键字final、static
  • 原文地址:https://www.cnblogs.com/Asurudo/p/11475286.html
Copyright © 2011-2022 走看看