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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

线性代数问卷调查反馈——Find The Determinant III,Takahashi‘s Basics in Education and Learning

發布時間:2023/12/3 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 线性代数问卷调查反馈——Find The Determinant III,Takahashi‘s Basics in Education and Learning 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • Find The Determinant III
    • source
    • code
  • Takahashi's Basics in Education and Learning
    • source
    • code

Find The Determinant III

source

高斯消元求行列式的模板題

code

#include <cstdio> #include <iostream> using namespace std; #define maxn 205 #define int long long int n, mod; int x[maxn][maxn];signed main() {while( ~ scanf( "%lld %lld", &n, &mod ) ) {for( int i = 1;i <= n;i ++ )for( int j = 1;j <= n;j ++ )scanf( "%lld", &x[i][j] );int ans = 1;for( int i = 1;i <= n;i ++ ) {for( int j = i + 1;j <= n;j ++ )while( x[j][i] ) {//類似于輾轉相除 這樣就不會有非整數倍數取模情況了 int t = x[i][i] / x[j][i];for( int k = i;k <= n;k ++ ) {x[i][k] = ( x[i][k] - x[j][k] * t ) % mod;swap( x[i][k], x[j][k] );}ans *= -1;}ans = ans * x[i][i] % mod;}printf( "%lld\n", ( ans + mod ) % mod );}return 0; }

Takahashi’s Basics in Education and Learning

source

數學作業的老子版,解法幾乎完全一樣

只不過要考慮加ddd后位數變化多少位的小細節

code

#include <cstdio> #include <cstring> #include <iostream> using namespace std; #define int long long int n, a0, d, mod;struct matrix {int n, m;int c[3][3];matrix(){ n = m = 0, memset( c, 0, sizeof( c ) ); }int * operator [] ( int i ) { return c[i]; }matrix operator * ( matrix t ) const {matrix ans;ans.n = n, ans.m = t.m;for( int i = 0;i < n;i ++ )for( int j = 0;j < t.m;j ++ )for( int k = 0;k < m;k ++ )ans[i][j] = ( ans[i][j] + c[i][k] * t.c[k][j] ) % mod;return ans;} }g, ret;matrix qkpow( matrix x, int y ) {matrix ans;ans.n = ans.m = x.n;for( int i = 0;i < 3;i ++ )ans[i][i] = 1;while( y ) {if( y & 1 ) ans = ans * x;x = x * x;y >>= 1;}return ans; }signed main() {scanf( "%lld %lld %lld %lld", &n, &a0, &d, &mod );ret.n = 1, ret.m = g.n = g.m = 3;ret[0][0] = a0 % mod;ret[0][1] = ( a0 + d ) % mod;ret[0][2] = g[1][0] = g[1][1] = g[2][2] = 1;g[2][1] = d % mod;n --;int End = a0 + d * n;for( int i = 0, mi = 10, last = 0;i < 18 && last < n;i ++, mi *= 10 )if( a0 + d < mi ) {int t = min( mi - 1, End );int now = ( t - a0 ) / d;while( a0 + d * ( now + 1 ) < t ) now ++;g[0][0] = mi % mod;ret = ret * qkpow( g, now - last );last = now;}printf( "%lld\n", ret[0][0] ); return 0; }

總結

以上是生活随笔為你收集整理的线性代数问卷调查反馈——Find The Determinant III,Takahashi‘s Basics in Education and Learning的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。