日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

方程的解_NOI导刊2010提高(01) 组合数

發(fā)布時間:2023/12/20 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 方程的解_NOI导刊2010提高(01) 组合数 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

題目描述

佳佳碰到了一個難題,請你來幫忙解決。

對于不定方程a1+a2+…+ak-1+ak=g(x),其中k≥2且k∈N,x是正整數(shù),g(x)=x^x mod 1000(即x^x除以1000的余數(shù)),x,k是給定的數(shù)。我們要求的是這個不定方程的正整數(shù)解組數(shù)。

舉例來說,當k=3,x=2時,分別為(a1,a2,a3)=(2,1,1)'(1,2,1),(1,1,2)。

輸入輸出格式

輸入格式:

輸入文件equation.in有且只有一行,為用空格隔開的兩個正整數(shù),依次為k,x。

輸出格式:

輸出文件equation.out有且只有一行,為方程的正整數(shù)解組數(shù)。

輸入輸出樣例

輸入樣例#1: 復制 3 2 輸出樣例#1: 復制 3

說明

對于40%的數(shù)據(jù),ans≤10^16;對于100%的數(shù)據(jù),k≤100,x≤2^31-1,k≤g(x)。

_NOI導刊2010提高(01)

隔板法:

C(x-1,k-1) ;

然后高精度就行了;

#include<iostream> #include<cstdio> #include<algorithm> #include<cstdlib> #include<cstring> #include<string> #include<cmath> #include<map> #include<set> #include<vector> #include<queue> #include<bitset> #include<ctime> #include<deque> #include<stack> #include<functional> #include<sstream> //#include<cctype> //#pragma GCC optimize(2) using namespace std; #define maxn 900005 #define inf 0x7fffffff //#define INF 1e18 #define rdint(x) scanf("%d",&x) #define rdllt(x) scanf("%lld",&x) #define rdult(x) scanf("%lu",&x) #define rdlf(x) scanf("%lf",&x) #define rdstr(x) scanf("%s",x) typedef long long ll; typedef unsigned long long ull; typedef unsigned int U; #define ms(x) memset((x),0,sizeof(x)) const long long int mod = 1e9 + 7; #define Mod 1000000000 #define sq(x) (x)*(x) #define eps 1e-3 typedef pair<int, int> pii; #define pi acos(-1.0) //const int N = 1005; #define REP(i,n) for(int i=0;i<(n);i++) typedef pair<int, int> pii; inline ll rd() {ll x = 0;char c = getchar();bool f = false;while (!isdigit(c)) {if (c == '-') f = true;c = getchar();}while (isdigit(c)) {x = (x << 1) + (x << 3) + (c ^ 48);c = getchar();}return f ? -x : x; }ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a%b); } int sqr(int x) { return x * x; }/*ll ans; ll exgcd(ll a, ll b, ll &x, ll &y) {if (!b) {x = 1; y = 0; return a;}ans = exgcd(b, a%b, x, y);ll t = x; x = y; y = t - a / b * y;return ans; } */const int W = 10000000; int x, k; struct bigint {int a[25], len;bigint() {ms(a); len = 0;}bigint operator +(const bigint &rhs)const {bigint c; int x = 0;c.len = max(len, rhs.len);for (int i = 1; i <= c.len; i++) {c.a[i] = a[i] + rhs.a[i] + x;x = c.a[i] / W; c.a[i] %= W;}for (; x; x /= W)c.a[++c.len] = x % W;return c;}void print() {cout << a[len];for (int i = len - 1; i >= 1; i--) {for (int j = 10; a[i] * j < W; j *= 10)putchar(48);cout << a[i];}} }c[1003][1003]; int qpow(int x, int y) {int res = 1;while (y) {if (y % 2)res = 1ll * res*x % 1000;x = x * x % 1000; y >>= 1;}return res; }int main() {//ios::sync_with_stdio(0);rdint(k); rdint(x); x %= 1000; x = qpow(x, x);for (int i = 0; i < x; i++) {for (int j = 0; j <= i; j++) {if (!j || j == i)c[i][j].a[c[i][j].len = 1] = 1;else c[i][j] = c[i - 1][j] + c[i - 1][j - 1];}}c[x - 1][k - 1].print();return 0; }

?

轉(zhuǎn)載于:https://www.cnblogs.com/zxyqzy/p/10270189.html

總結(jié)

以上是生活随笔為你收集整理的方程的解_NOI导刊2010提高(01) 组合数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。