一維多項式多組求值,利用系數預處理法對多項式p(x)=an-1x^n-1+an-2x^n-2+...+a1x+a0,進行多組求值。其中n=2^k
標簽: 多項式
上傳時間: 2017-05-29
上傳用戶:戀天使569
The code performs a number (ITERS) of iterations of the Bailey s 6-step FFT algorithm (following the ideas in the CMU Task parallel suite). 1.- Generates an input signal vector (dgen) with size n=n1xn2 stored in row major order In this code the size of the input signal is NN=NxN (n=NN, n1=n2=N) 2.- Transpose (tpose) A to have it stored in column major order 3.- Perform independent FFTs on the rows (cffts) 4.- Scale each element of the resulting array by a factor of w[n]**(p*q) 5.- Transpose (tpose) to prepair it for the next step 6.- Perform independent FFTs on the rows (cffts) 7.- Transpose the resulting matrix The code requires nested Parallelism.
標簽: iterations performs Bailey number
上傳時間: 2014-01-05
上傳用戶:libenshu01
關于制造回文 描述 回文,亦稱回環,是正讀反讀都能讀通的句子,亦有將文字排列成圓圈者,是一種修辭方式和文字游戲。回文運用得當,可以表現兩種事物或現象相互依靠或排斥的關系。總有人以為回文是英文的專利,其實不然,中文中也有很多回文的例子,譬如: 鶯啼岸柳弄春晴, 柳弄春晴夜月明。 明月夜晴春弄柳, 晴春弄柳岸啼鶯。 看著很有意思,可要想寫出回文,并不是一件很容易的事情。如果有一個字符串,怎樣才能插入最少的內容,把它變成回文呢? 例如,要想把字符串 "Zb3bd" 變成回文,就需要插入兩個字符,變成 "dZb3bZd" 或者 "Zdb3bdZ",插入一個字符,是肯定不行的。 輸入 輸入的第一行是字符串的長度 N,3 <= N <= 5000,第二行是一個長度為 N 的字符串。該字符串由英文大小寫字母和數字組成,英文大寫字母和小寫字母是不同的。 輸出 程序輸出要把該字符串變成回文,需要插入的最少字符數。
標簽: 制造
上傳時間: 2014-01-24
上傳用戶:gundamwzc
OFDM程序,這么安排矩陣的目的是為了構造共軛對稱矩陣 共軛對稱矩陣的特點是 在ifft/fft的矢量上 N點的矢量 在0,N/2點必須是實數 一般選為0 1至N/2點 與 (N/2)+1至N-1點關于N/2共軛對稱
上傳時間: 2014-02-05
上傳用戶:woshiayin
任務:一堆猴子都有編號,編號是1,2,3 ...m ,這群猴子(m個)按照1-m的順序圍坐一圈,從第1開始數,每數到第N個,該猴子就要離開此圈,這樣依次下來,直到圈中只剩下最后一只猴子,則該猴子為大王。 功能:輸入數據:輸入m,n(m,n 為整數且n<m) 輸出形式:中文提示按照m個猴子,數n 個數的方法,輸出為大王的猴子是幾號 ,建立一個函數來實現此功能
標簽:
上傳時間: 2014-01-25
上傳用戶:athjac
#include <iostream> using namespace std; int main(){ int t; cin>>t; while(t--){ long long n; cin>>n; if(n%2==1) cout<<(n*n-1)/4<<endl; else if (n%4==0) cout <<(n*n)/4-1<<endl; else{ if(n==2) cout<<1<<endl; else{ long long k=n/2-1; cout <<k*k+2*k-3<<endl; } } } return 0; }
標簽: 天津大學acm4022 代碼
上傳時間: 2015-04-20
上傳用戶:nr607
題目描述 蛇行矩陣 Problem 蛇形矩陣是由1開始的自然數依次排列成的一個矩陣上三角形。 輸入 Input 本題有多組數據,每組數據由一個正整數N組成。(N不大于100) 輸出 Output 對于每一組數據,輸出一個N行的蛇形矩陣。兩組輸出之間不要額外的空行。 矩陣三角中同一行的數字用一個空格分開。行尾不要多余的空格。 樣例輸入 5 樣例輸出 1 3 6 10 15 2 5 9 14 4 8 13 7 12 11
上傳時間: 2016-02-29
上傳用戶:lwol2007
實驗源代碼 //Warshall.cpp #include<stdio.h> void warshall(int k,int n) { int i , j, t; int temp[20][20]; for(int a=0;a<k;a++) { printf("請輸入矩陣第%d 行元素:",a); for(int b=0;b<n;b++) { scanf ("%d",&temp[a][b]); } } for(i=0;i<k;i++){ for( j=0;j<k;j++){ if(temp[ j][i]==1) { for(t=0;t<n;t++) { temp[ j][t]=temp[i][t]||temp[ j][t]; } } } } printf("可傳遞閉包關系矩陣是:\n"); for(i=0;i<k;i++) { for( j=0;j<n;j++) { printf("%d", temp[i][ j]); } printf("\n"); } } void main() { printf("利用 Warshall 算法求二元關系的可傳遞閉包\n"); void warshall(int,int); int k , n; printf("請輸入矩陣的行數 i: "); scanf("%d",&k); 四川大學實驗報告 printf("請輸入矩陣的列數 j: "); scanf("%d",&n); warshall(k,n); }
上傳時間: 2016-06-27
上傳用戶:梁雪文以
1.Describe a Θ(n lg n)-time algorithm that, given a set S of n integers and another integer x, determines whether or not there exist two elements in S whose sum is exactly x. (Implement exercise 2.3-7.)
上傳時間: 2017-04-01
上傳用戶:糖兒水嘻嘻
1.Describe a Θ(n lg n)-time algorithm that, given a set S of n integers and another integer x, determines whether or not there exist two elements in S whose sum is exactly x. (Implement exercise 2.3-7.) #include<stdio.h> #include<stdlib.h> void merge(int arr[],int low,int mid,int high){ int i,k; int *tmp=(int*)malloc((high-low+1)*sizeof(int)); int left_low=low; int left_high=mid; int right_low=mid+1; int right_high=high; for(k=0;left_low<=left_high&&right_low<=right_high;k++) { if(arr[left_low]<=arr[right_low]){ tmp[k]=arr[left_low++]; } else{ tmp[k]=arr[right_low++]; } } if(left_low<=left_high){ for(i=left_low;i<=left_high;i++){ tmp[k++]=arr[i]; } } if(right_low<=right_high){ for(i=right_low;i<=right_high;i++) tmp[k++]=arr[i]; } for(i=0;i<high-low+1;i++) arr[low+i]=tmp[i]; } void merge_sort(int a[],int p,int r){ int q; if(p<r){ q=(p+r)/2; merge_sort(a,p,q); merge_sort(a,q+1,r); merge(a,p,q,r); } } int main(){ int a[8]={3,5,8,6,4,1,1}; int i,j; int x=10; merge_sort(a,0,6); printf("after Merging-Sort:\n"); for(i=0;i<7;i++){ printf("%d",a[i]); } printf("\n"); i=0;j=6; do{ if(a[i]+a[j]==x){ printf("exist"); break; } if(a[i]+a[j]>x) j--; if(a[i]+a[j]<x) i++; }while(i<=j); if(i>j) printf("not exist"); system("pause"); return 0; }
上傳時間: 2017-04-01
上傳用戶:糖兒水嘻嘻