设为首页 加入收藏

TOP

Codeforces 476C Dreamoon and Sums (水
2015-07-20 17:26:16 来源: 作者: 【 】 浏览:4
Tags: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 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        #include 
        #include 
        
          template 
         
           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 
          
            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<
           
            

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇HDU 4010 Query on The Trees 下一篇POJ 1061 青蛙的约会(扩展欧几里..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·微服务 Spring Boot (2025-12-26 18:20:10)
·如何调整 Redis 内存 (2025-12-26 18:20:07)
·MySQL 数据类型:从 (2025-12-26 18:20:03)
·Linux Shell脚本教程 (2025-12-26 17:51:10)
·Qt教程,Qt5编程入门 (2025-12-26 17:51:07)