【HDU5810】Balls and Boxes(数学题)

来源:互联网 发布:怎么开好淘宝店 编辑:程序博客网 时间:2024/05/17 22:00

记录一个菜逼的成长。。

找规律推导
ans = n*(m-1)/m^2;

#include <cstdio>#include <iostream>#include <cstring>#include <string>#include <algorithm>#include <cstdlib>#include <vector>#include <set>#include <map>#include <queue>#include <list>#include <deque>#include <cctype>#include <bitset>#include <cmath>using namespace std;#define ALL(v) (v).begin(),(v).end()#define cl(a) memset(a,0,sizeof(a))typedef long long LL;typedef unsigned long long ULL;typedef pair<int,int> PII;typedef pair<LL,LL> PLL;const int INF = 0x3f3f3f3f;int main(){    LL n,m;    while(~scanf("%lld%lld",&n,&m)){        if(!n && !m)break;        LL x = n * ( m - 1 );        LL y = m * m;        LL gcd = __gcd(x,y);        printf("%lld/%lld\n",x/gcd,y/gcd);    }    return 0;}
0 0
原创粉丝点击