Problem 2238 Daxia & Wzc ' s problem 1627 instant movement

Source: Internet
Author: User

http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1627

http://acm.fzu.edu.cn/problem.php?pid=2238

The corresponding 51NOD this problem, first put n--and not m--

The formula of the second set

#include <cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<algorithm>#include<assert.h>#defineIOS Ios::sync_with_stdio (False)using namespacestd;#defineINF (0X3F3F3F3F)typedefLong Long intLL; #include<iostream>#include<sstream>#include<vector>#include<Set>#include<map>#include<queue>#include<string>ll Quick_pow (ll A, ll B, ll MOD) {//solving the value of a a^b%modLLBase= a%MOD; LL ans=1;//multiplied, so here is 1     while(b) {if(B &1) {ans= (ans *Base)% MOD;//If this is a big data, use Quick_mul.        }        Base= (Base*Base)% MOD;//notice. Note here that each time the base is its own base timesb >>=1; }    returnans;} ll C (ll N, ll M, ll MOD) {if(N < m)return 0;//To prevent SB from circulating in the time of Lucas    if(n = = m)return 1; LL ans1=1; LL Ans2=1; LL MX= Max (n-m, M);//this is also necessary. It's about the biggest one.LL mi = n-MX;  for(inti =1; I <= mi; ++i) {ans1= ans1 * (mx + i)%MOD; Ans2= Ans2 * I%MOD; }    return(ANS1 * QUICK_POW (ANS2, MOD-2, MoD)% mod);//Put it in the last place, or it'll be slow.}Const intMOD = 1e9 +7;voidWork () {intN, M; CIN>> N >>m; cout<< C (n + M-4N2, MOD) <<Endl;}intMain () {#ifdef local freopen ("Data.txt","R", stdin);//freopen ("Data.txt", "w", stdout);#endifWork (); return 0;}
51NOD
#include <cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<algorithm>using namespacestd;#defineINF (0X3F3F3F3F)typedefLong Long intLL; #include<iostream>#include<sstream>#include<vector>#include<Set>#include<map>#include<queue>#include<string>LL A, D, M, I;Const intMOD =1000000007; ll Quick_pow (ll A, ll B, ll MOD) {//solving the value of a a^b%modLLBase= a%MOD; LL ans=1;//multiplied, so here is 1     while(b) {if(B &1) {ans= (ans *Base)% MOD;//If this is a big data, use Quick_mul.        }        Base= (Base*Base)% MOD;//Notice//note here that each time the base is its own base timesb >>=1; }    returnans;} ll C (ll N, ll M, ll MOD) {if(N < m)return 0;//To prevent SB from circulating in the time of Lucas    if(n = = m)return 1; LL ans1=1; LL Ans2=1; LL MX= Max (n-m, M);//this is also necessary. It's about the biggest one.LL mi = n-MX;  for(inti =1; I <= mi; ++i) {ans1= ans1 * (mx + i)%MOD; Ans2= Ans2 * I%MOD; }    return(ANS1 * QUICK_POW (ANS2, MOD-2, MoD)% mod);//Put it in the last place, or it'll be slow.}ll Lucas (ll N, ll M, ll MOD) {ll ans=1;  while(N && m &&ans) {ans= ans * C (n% mod, m% mod, MoD)%MOD; N/=MOD; M/=MOD; }    returnans;}voidWork () {if(i = =1) {printf ("%lld\n", a); return; } LL ans= (C (m + i-1, M, MoD) * A% mod + C (m + i-1I2, MoD) * d% MoD)%MOD; printf ("%lld\n", ans); return ;}intMain () {#ifdef local freopen ("Data.txt","R", stdin);#endif     while(SCANF ("%lld%lld%lld%lld", &a, &d, &m, &i)! =EOF) work (); return 0;}
Fzuoj

Problem 2238 Daxia & Wzc ' s problem 1627 instant movement

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.