hdu 2643 Rank hdu 2512 一卡通大冒險 stirling (斯特靈數)的應用

hdu 2643/* 第二類Stirling數是把包含n個元素的集合劃分為正好k個非空子集的方法的數目。 遞推公式為: S(n,k) = 0(n<k||k=0), S(n,n) = S(n,1) = 1, S(n,k) = S(n-1,k-1) + kS(n-1,k). */#include<stdio.h>#define LL long long#define nmax 101#define nnum 20090126LLLL num[nmax][nmax],

hdu 2199 Can you solve this equation? 二分

 /* * hdu2199.c * * Created on: 2011-10-9 * Author: bjfuwangzhu*/#include<stdio.h>#include<math.h>#define eps 1.0e-10double f(double x) {return 8.0 * pow(x, 4.0) + 7.0 * pow(x, 3.0) + 2.0 * pow(x, 2.0) + 3 * x + 6;}void

選擇、插入、冒泡排序(從小到大)

package com.wangzhu.main;public class Main {/** * @param args */public static void main(String[] args) {work(new int[] { 1, 1, 1, 1, 1 });work(new int[] { 5, 4, 3, 2, 1 });work(new int[] { 1, 2, 3, 4, 5 });work(new int[] { 1, 7, 2, 3, 3, 4, 5, 5, 7,

幻方(zjut1005) 與 反幻方(hdu 3927)

zjut1005  做幻方此題是求解奇幻方記:關鍵是確定下一個數填的位置,規律是:1以後的每一個數只能填在它所在位置的下一行的下一列(記為A),如果A已經有數,就把下一個數填在當前這個數的上面(即與這個數同一列的上一個位置)#include<stdio.h>#include<string.h>#define nmax 101int num[nmax][nmax];int main() {#ifndef ONLINE_JUDGE freopen("data.in",

jquery easyui 驗證框的使用

使用過程中的一積累,備查。EasyUI 驗證框使用方法://***************************missingMessage:未填寫時顯示的資訊validType:驗證類型見下樣本invalidMessage:無效的資料類型時顯示的資訊required="true" 必填項class="easyui-validatebox" 文本驗證class="easyui-numberbox" 數字驗證*****************************//0、調用資料驗證方法   

hdu 3049 Data Processing

利用P是素數所以有:(1). A/B%P=((A%(B*P))/B)%p;(2). A/B%P=A*(B`)%P 其中B`是B對於P的逆元方法一:#include<stdio.h>int main() {int i, t, x, v = 1, n, m, ans;long long P, a[51000], sum;scanf("%d", &t);while (t-- && scanf("%d", &n)) {a[0] = 1;sum = 0;P =

TreeSet的使用:獲得一組數中的不同數(排序)

import java.io.BufferedInputStream;import java.util.Iterator;import java.util.Scanner;import java.util.Set;import java.util.TreeSet;public class Main {public static void main(String[] args) {Scanner cin = new Scanner(new

hdu 1521 排列組合 指數型母函數

 /* * hdu1521.c * * Created on: 2011-8-31 * Author: 王竹*/#include<stdio.h>#include<string.h>#define nmax 15int num[nmax];double res[nmax], fac[nmax], temp[nmax];void init(int n) {int i; fac[0] = 1;for (i = 1; i <= n; i++) {

hdu 2669 Romantic 擴充歐幾裡德

利用擴充歐幾裡德演算法可以解方程ax+by=c.當使用擴充歐幾裡德演算法時,當x+b時,y-a。歐幾裡德演算法           定理:gcd(a,b) = gcd(b,a mod b)                       證明:a可以表示成a = kb + r,則r = a mod b 假設d是a,b的一個公約數,則有 d|a, d|b,而r = a - kb,因此d|r 因此d是(b,a mod b)的公約數 假設d 是(b,a mod b)的公約數,則 d | b , d |r

hdu 3923 Invoker polya 定理

 /* * hdu3923.c * * Created on: 2011-9-20 * Author: bjfuwangzhu*/#include<stdio.h>#include<math.h>#define LL long long#define nnum 1000000007LL x, y;LL modular_exp(int a, int b) { LL res, temp; res = 1 % nnum,temp = a %

判斷一個整數是否是奇數的小解

使用n%2==1判斷是否是奇數:import java.io.BufferedInputStream;import java.util.Scanner;public class Main { /** * @param args */ public static void main(String[] args) { int a; Scanner cin = new Scanner(new BufferedInputStream(System.

數論小結–轉載

轉載於:http://blog.csdn.net/xieshimao/article/details/6425099斷斷續續的學習數論已經有一段時間了,學得也很雜,現在進行一些簡單的回顧和總結。學過的東西不能忘啊。。。 1、本原勾股數:概念:一個三元組(a,b,c),其中a,b,c沒有公因數而且滿足:a^2+b^2=c^2首先,這種本原勾股數的個數是無限的,而且構造的條件滿足:a=s*t,b=(s^2-t^2)/2,c=(s^2+t^2)/2其中s>t>=1是任意沒有公因數的奇數!由

pku 2480 Longge’s problem 最大公約數的和

做法:直接求過不了只能考慮  對於gcd(M,N)=i 有Ci個M滿足此式 答案便是∑(Ci*i)gcd(M,N)=i  <=> gcd(M/i,N/i)=1 而求gcd(M/i,N/i)=1 有多少個M/i滿足 這便是歐拉函數Phi()的定義所以就轉化為了求Phi(N/i)枚舉每個 M|N  求出Phi(N/i)  答案便是 ∑(Phi(N/i)*i)那麼如何枚舉每個  M|N 呢?很簡單 枚舉1到sqrt(N)的所有整數,所有的約數便是 j|N

hrbeu 1347 Euler 歐拉值

 #include<stdio.h>#include<string.h>#include<math.h>#define LL long long#define nmax 3000001int prime[nmax], phi[nmax];int plen;void init() {int i, j; memset(phi, 0, sizeof(phi));for (i = 2, plen = 0; i < nmax; i++) {if (

fafu 1079 幫冬兒忙 組合數包含因數個數

對於本題的因數m,只需要將其化為素因子的乘積形式,其中每一個素因子的個數為mi,之後只需要求得每一個素因子pi在組合數中的個數Ci,然後將取Ci/mi中的最小的那個,就是該因數在組合數中的個數。代碼如下:/* * fafu1079.c * * Created on: 2011-10-9 * Author: bjfuwangzhu*/#include<stdio.h>#include<string.h>#include<math.h>#define

poj 3734 Blocks 指數型母函數

遞推公式:E(t)=(1+t+t^2/2!+......+..)^2*(1+t^2/2!+t^4/4!+..+)^2                   =e^2t*((e^t+e^-t)/2)^2                   =1/4(e^4t+2*e^2t+1)                   =sigma(1/4*[4^n+2*2^n+1]*t^n/n!) n=0,1,2,,,  ==> a(n)=1/4(4^n+2*2^n)  /* * poj3734.c * *

hdu 1042 N!

 #include<stdio.h>#define nmax 100000int num[nmax];void solve(int n) {int i, j, k, r;for (i = 1, num[0] = 1, k = 0, r = 0; i <= n; i++) {for (j = 0; j <= k; j++) { num[j] = num[j] * i + r;if (num[j] >= nmax) {

一組數中是否存在若干數之和等於已知數

1.是否存在兩個數的和與已知數(key)相等。A:窮舉:在數組中任選兩個數,判斷是否等於已知數,複雜度O(N^2).B:二分:先排序(若是有序,則不需要),然後二分尋找M-array[i]是否存在於這個數組,複雜度O(N*log(N)).C:先排序(若是有序,則不需要),然後用兩個指標(頭指標head與尾指標tail),當*head+*tail>key,則tail--,若是小於,則是head++,若是相等,則是存在。對於C:int getResult(int *num, int

POJ about lcm

由題知:g(n)=sigma{phi(n/d)*n/d},d|nf(n)=(g(n)+1)/2由於歐拉函數的積性,phi(n*m)=phi(n)*phi(m),gcd(n,m)=1所以,n=pi(pi^ci)故g(n)=g(pi(pi^ci))。g(n)=pi(g(pi^ci)g(pi^ci)=sigma(phi(pi^ci)pi^ci)而對於phi(pi^ci)(pi-1)*(pi^(ci-1)至此就這題就解決了!My Code:逾時的代碼:LL sumlcm(int n) {int te =

轉載 高效實用的異或操作

異或(XOR)是一種位元運算符,相同為0,相異為1如0^1=1,0^0=0,1^1=0異或滿足交換律、結合律a^b=b^aa^(b^c)=a^b^c=(a^b)^ca^b^c^d=a^d^c^b異或是一種位元運算,能夠高效地巧妙地完成一些功能1、  實現兩個數的交換,swap函數 public static void swap(int[] arr, int i, int j) {arr[i] = arr[i] ^ arr[j];arr[j] = arr[i] ^ arr[j];arr[i] =

總頁數: 61357 1 .... 26844 26845 26846 26847 26848 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.