1. 程式人生 > >Codevs 3194 基因變異

Codevs 3194 基因變異

label namespace style 時間段 des http pad pull amp

Codevs 3194 基因變異

時間限制: 1 s 空間限制: 32000 KB 題目等級 : 黃金 Gold 題解 題目描述 Description

小毛終於來到了冥王星,這是一顆已經不屬於行星的矮行星,它的表面溫度低於-220度。在這裏,小毛驚奇的發現,他帶來的厭氧菌開始了基因變異,裂變的速度與光照時間(秒)成乘積關系,公式如下:細菌個數=原個數*時間(秒),而如果關閉照明,則細菌停止繁殖裂變。現在已知n個細菌,經過m段光照時間後,一共有多少個細菌呢?

輸入描述 Input Description

第一行為兩個整數N,M(均小於1000),第2行為m個時間段的時間(均小於10000)。

輸出描述 Output Description

僅一個正整數,表示最後的細菌個數。

樣例輸入 Sample Input

4 3

100 20 3

樣例輸出 Sample Output

24000

數據範圍及提示 Data Size & Hint

沒必要啦

分類標簽 Tags 點此展開

容斥原理 數論 嚴重懷疑標簽的真實性~~ 明明是高精乘法 (⊙v⊙)嗯~ 代碼:
#include<iostream>
#include
<cstdio> using namespace std; const int N = 100010; int n,m,x,lena,lenb; int a[N],b[N],c[N]; int p; int main() { cin>>n>>m; int t = n; while(t) { b[++p] = t%10; t/=10; } lenb = p,p = 0; for(int k=1; k<=m; k++) { cin>>x;
while(x) { a[++p] = x%10; x/=10; } lena = p,p=0; for(int i=1; i<=lena; i++) { x = 0; for(int j=1; j<=lenb; j++) { c[i+j-1] += a[i]*b[j]+x; x = c[i+j-1]/10; c[i+j-1]%=10; } c[i+lenb] = x; } int lenc = lena + lenb; while(c[lenc]==0&&lenc>1) lenc--; lenb=lenc; for(int i=1; i<=lenb; i++){ b[i] = c[i]; c[i] = 0; } } for(int i=lenb; i>0; i--) cout<<b[i]; return 0; }

自己選的路,跪著也要走完!!!

Codevs 3194 基因變異