HDU 5793 A Boring Question 多校训练

{“type”:3,”value”:{“videosourcetype”:1,”vid”:”k087545a7k5″,”desc”:””,”img”:”

There are an equation. 
∑0≤k1,k2,⋯km≤n∏1⩽j<m(kj+1kj)%1000000007=?∑0≤k1,k2,⋯km≤n∏1⩽j<m(kj+1kj)%1000000007=? 
We define that (kj+1kj)=kj+1!kj!(kj+1−kj)!(kj+1kj)=kj+1!kj!(kj+1−kj)! . And (kj+1kj)=0(kj+1kj)=0 while kj+1<kjkj+1<kj. 
You have to get the answer for each nn and mm that given to you. 
For example,if n=1n=1,m=3m=3, 
When k1=0,k2=0,k3=0,(k2k1)(k3k2)=1k1=0,k2=0,k3=0,(k2k1)(k3k2)=1; 
Whenk1=0,k2=1,k3=0,(k2k1)(k3k2)=0k1=0,k2=1,k3=0,(k2k1)(k3k2)=0; 
Whenk1=1,k2=0,k3=0,(k2k1)(k3k2)=0k1=1,k2=0,k3=0,(k2k1)(k3k2)=0; 
Whenk1=1,k2=1,k3=0,(k2k1)(k3k2)=0k1=1,k2=1,k3=0,(k2k1)(k3k2)=0; 
Whenk1=0,k2=0,k3=1,(k2k1)(k3k2)=1k1=0,k2=0,k3=1,(k2k1)(k3k2)=1; 
Whenk1=0,k2=1,k3=1,(k2k1)(k3k2)=1k1=0,k2=1,k3=1,(k2k1)(k3k2)=1; 
Whenk1=1,k2=0,k3=1,(k2k1)(k3k2)=0k1=1,k2=0,k3=1,(k2k1)(k3k2)=0; 
Whenk1=1,k2=1,k3=1,(k2k1)(k3k2)=1k1=1,k2=1,k3=1,(k2k1)(k3k2)=1. 
So the answer is
4.

随着Github上star的Project越来越多,有必要对过往的Project进行整理,下面是我使用和了解到的一些开源框架(按Star量排序)。附上我的
Github

InputThe first line of the input contains the only integer TT,(1≤T≤10000)(1≤T≤10000) 
Then TT lines follow,the i-th line contains two
integers nn,mm,(0≤n≤109,2≤m≤109)(0≤n≤109,2≤m≤109) 
OutputFor
each nn and mm,output the answer in a single
line.Sample Input

  1. mg游戏官网,开源框架集合
2
1 2
2 3
  • awesome-android-ui
    — 27.8k

  • android-open-project
    — 25.6k

  • open-source-android-apps
    — 6.5k

Sample Output

  1. 图标素材
3
13

根据题意可以推出公式 
∑0≤k1,k2,⋯km≤n∏1⩽j<m(kj+1kj)%1000000007= m^0 + m^1 + m^2 + ... + m^n = ( pow(m,n+1) - 1 / m - 1 ) % mod;
注意这个题目中是除法后取余,所以取余要用逆元取余
下面贴出两种可以用逆元取余的方法

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#define mod 1000000007
using namespace std;
typedef long long ll;
ll qow(ll a,ll b) {
    ll ans = 1;
    while( b ) {
        if( b&1 ) {
            ans = ans*a%mod;
        }
        a = a*a%mod;
        b /= 2;
    }
    return ans;
}
int main() {
    ll T;
    cin >> T;
    while( T -- ) {
        ll n,m;
        cin >> n >> m;
        ll sum = 1,num=1;
        if( n == 0 ) {
            cout << sum << endl;
            continue;
        }
        num = (qow(m,n+1)-1)*qow(m-1,mod-2)%mod; //费马小定理的求法
        /*用qow(m-1,mod-2)对m-1进行逆元取余*/
        cout << num << endl;
    }
    return 0;
}
  • material-design-icons
    — 33k

 

  1. Rx系列
#include <cstdio>
#include <cmath>
#define MAX 100005
#define mod 1000000007

using namespace std;

long long multi(long long a, long long b)//快速幂
{
    long long ret = 1;
    while(b > 0)
    {
        if(b & 1)
            ret = (ret * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ret;
}

long long exgcd(long long a, long long b, long long &x, long long &y)//扩展欧几里得
{
    if(!b)
    {
        x = 1;
        y = 0;
        return a;
    }
    long long d = exgcd(b, a % b, x, y);

    long long tmp = x;
    x = y;
    y = tmp - a / b * y;

    return d;
}

int main()
{
    int T;
    scanf("%d", &T);
    while(T--)
    {
        long long n, m, x, y;
        scanf("%lld %lld", &n, &m);
        long long mul = (multi(m, n + 1) - 1) % mod;
        long long d = exgcd(m - 1, mod, x, y);//若这里mod的位置填写mod * (m - 1),最终计算时需要让x和mod都除以d
        x *= mul;
        x /= d;//因为m - 1和mod是互质的,这句可以去掉。
        x = (x % mod + mod) % mod;//防止最终结果为负数
        printf("%lld\n", x);
    }
    return 0;
}
  • RxJava
    — 30k

  • RxAndroid
    — 14.8k

  • RxBinding
    — 6.8k

  • RxDownload
    — 2.8k

 

  1. 网络访问
 
  • retrofit
    — 25.7k

  • okhttp
    — 24.4k

  1. 图形
  • MPAndroidChart
    — 20k
  1. 控件绑定
  • butterknife
    — 19.6k
  1. 图片加载
  • glide
    — 19.6k

  • picasso
    — 14.7k

  • fresco
    — 13.9k

  1. 内存泄漏
  • leakcanary
    — 18k
  1. 动画
  • lottie-android
    — 18k
  1. 播放器
  • ijkplayer
    — 17.1k

  • JiaoZiVideoPlayer
    — 5.7k

  • Music-Player
    — 2.7k

  1. 事件传递
  • EventBus
    — 16.9k
  1. 工具
  • AndroidUtilCode
    — 15.4k
  1. RecycleView
  • BaseRecyclerViewAdapterHelper
    — 11.7k
  1. 数据解析
  • gson
    — 11.3k
  1. 热更新
  • tinker
    — 10.9k
  1. 音乐播放器
  • android-UniversalMusicPlayer
    — 8.8k

  • StylishMusicPlayer
    — 3k

网站地图xml地图