zoukankan      html  css  js  c++  java
  • Codeforces 476C Dreamoon and Sums (水

    题目链接:点击打开链接

    题意:

    给定a,b

    对于一个数x。若x是nice number,则满足(x/b)/(x%b) == [1,a](即结果在1-a之间)

    问:

    输出一个数表示 全部nice number的和。

    推一推公式就好。。

    结果就是

    b*(b-1)/2 * (a + b*( (1+a)*a/2 ) )

    #include <cstdio>
    #include <iostream>
    #include <cstring>
    #include <queue>
    #include <algorithm>
    #include <map>
    #include <cmath>
    template <class T>
    inline bool rd(T &ret) {
        char c; int sgn;
        if(c=getchar(),c==EOF) return 0;
        while(c!='-'&&(c<'0'||c>'9')) c=getchar();
        sgn=(c=='-')?-1:1;
        ret=(c=='-')?

    0:(c-'0'); while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0'); ret*=sgn; return 1; } template <class T> inline void pt(T x) { if (x <0) { putchar('-'); x = -x; } if(x>9) pt(x/10); putchar(x%10+'0'); } using namespace std; typedef long long ll; #define N 200010 const ll mod = 1000000007; ll a, b; int main() { while(cin>>a>>b){ ll ans = (a*(1+a))/2; ans %= mod; ans *= b; ans %= mod; ans += a; ans %= mod; ll B = b*(b-1)/2 % mod; ans *= B; ans %= mod; cout<<ans<<endl; } return 0; }



  • 相关阅读:
    Java中HashMap底层实现原理(JDK1.8)源码分析
    java io系列01之 "目录"
    数据结构与算法系列 目录
    Java 集合系列目录(Category)
    ls参数
    在PATH路径中添加新的路径
    目录相关的操作
    chmod
    属性类型
    ls -al
  • 原文地址:https://www.cnblogs.com/claireyuancy/p/6747963.html
Copyright © 2011-2022 走看看